如何在 Gitlab CI 上修复 'Rugged::ReferenceError: revspec 'origin/master' not found'
Posted
技术标签:
【中文标题】如何在 Gitlab CI 上修复 \'Rugged::ReferenceError: revspec \'origin/master\' not found\'【英文标题】:How to fix 'Rugged::ReferenceError: revspec 'origin/master' not found' on Gitlab CI如何在 Gitlab CI 上修复 'Rugged::ReferenceError: revspec 'origin/master' not found' 【发布时间】:2019-12-01 12:46:13 【问题描述】:我正在尝试为 Gitlab CI 设置 pronto,本地一切正常,但是当 pronto 在 Gitlab CI 上运行时“Rugged::ReferenceError: revspec 'origin/master' not found”错误引发
cache:
paths:
- vendor/
services:
- name: mysql:8.0
command: ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci", "--default-authentication-plugin=mysql_native_password"]
variables:
MYSQL_DATABASE: $MYSQL_DATABASE
MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
DB_USERNAME: $DB_USERNAME
DB_HOST: $DB_HOST
DISABLE_SPRING: 1
before_script:
- cp config/database.yml.example config/database.yml
- apt-get update -qq && apt-get install -y -qq cmake
- gem install bundler --no-document
- bundle check || bundle install --path vendor --jobs $(nproc) "$FLAGS[@]"
spec:
script:
- bundle exec rspec
pronto:
script:
- bundle exec pronto run -c origin/master --exit-code
Rugged::ReferenceError: revspec 'origin/master' not found
vendor/ruby/2.6.0/gems/pronto-0.10.0/lib/pronto/git/repository.rb:87:in `merge_base'
vendor/ruby/2.6.0/gems/pronto-0.10.0/lib/pronto/git/repository.rb:87:in `merge_base'
vendor/ruby/2.6.0/gems/pronto-0.10.0/lib/pronto/git/repository.rb:17:in `diff'
vendor/ruby/2.6.0/gems/pronto-0.10.0/lib/pronto.rb:62:in `run'
vendor/ruby/2.6.0/gems/pronto-0.10.0/lib/pronto/cli.rb:66:in `block in run'
vendor/ruby/2.6.0/gems/pronto-0.10.0/lib/pronto/cli.rb:64:in `chdir'
vendor/ruby/2.6.0/gems/pronto-0.10.0/lib/pronto/cli.rb:64:in `run'
vendor/ruby/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
vendor/ruby/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
vendor/ruby/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
vendor/ruby/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
vendor/ruby/2.6.0/gems/pronto-0.10.0/bin/pronto:6:in `<top (required)>'
vendor/ruby/2.6.0/bin/pronto:23:in `load'
vendor/ruby/2.6.0/bin/pronto:23:in `<top (required)>'
我希望在没有异常的情况下在 gitlab 上运行 pronto
【问题讨论】:
错误消息显示“未找到 revspec 'origin/master'”。你有一个名为“origin”的遥控器吗?您能否在问题中包含git remote -v
的输出?
【参考方案1】:
我不知道这是否是最好的解决方案,但这对我有用:
在您的 gitlab 存储库中,转到设置 -> CI/CD在通用管道 -> 管道的 Git 策略部分中,标记选项 git clone
而不是 git fetch
我还必须在 pronto
调用上方添加一个 git fetch
命令:
pronto:
script:
- git fetch
- bundle exec pronto run -c origin/master --exit-code
【讨论】:
以上是关于如何在 Gitlab CI 上修复 'Rugged::ReferenceError: revspec 'origin/master' not found'的主要内容,如果未能解决你的问题,请参考以下文章
使用 Gitlab CI docker-in-docker 时如何修复 docker 容器中的“sh: tsc not found”错误
Gitlab CI 设置错误 - 找不到 JavaScript 运行时