gitlab CI - 安装正确版本的 yarn
gitlab CI - installing correct version of yarn
我正在尝试使用 gitlab 设置 CI/CD,但我在特定时刻卡住了。下面是我的 .gitlab-ci.yml
文件:
image: "ruby:2.6"
before_script:
- ruby -v
- apt-get update -qy
- apt-get install -y nodejs
- apt-get install -y yarn
- yarn --version
- bundle install --path /cache
- bundle exec rails webpacker:install
test:
script:
- bundle exec rake db:create RAILS_ENV=test
- bundle exec rake test
CI 输出无错误地进行,直到它达到 $ bundle exec rails webpacker:install
。任务中止并显示此消息:
$ bundle exec rails webpacker:install
rails aborted!
ArgumentError: Malformed version number string 0.32+git
/builds/kvinklly/sample-app/bin/rails:5:in `<top (required)>'
/builds/kvinklly/sample-app/bin/spring:8:in `require'
/builds/kvinklly/sample-app/bin/spring:8:in `block in <top (required)>'
/builds/kvinklly/sample-app/bin/spring:5:in `tap'
/builds/kvinklly/sample-app/bin/spring:5:in `<top (required)>'
Tasks: TOP => webpacker:install => webpacker:check_yarn
(See full trace by running task with --trace)
我注意到 0.32+git 值很可能是安装的 yarn 版本,并验证了该版本:
$ yarn --version
0.32+git
有没有办法在 gitlab 上的 CI 脚本中指定较新版本或最新版本的 yarn?
我可以 post gemfile,但它是一个相当基本的 rails 应用程序,此时没有添加太多内容。
我使用以下方法让它工作:
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/ruby/tags/
image: "ruby:2.6"
# This is a basic example for a gem or script which doesn't use
# services such as redis or postgres
before_script:
- ruby -v # Print out ruby version for debugging
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
- apt-get update -qy
- apt-get install -y nodejs
- apt-get install -y yarn
- yarn install --check-files
- bundle install --path /cache # Install dependencies into ./vendor/ruby
- bundle exec rake webpacker:install
test:
stage: test
script:
- bundle exec rake db:create RAILS_ENV=test
- bundle exec rake test
我正在尝试使用 gitlab 设置 CI/CD,但我在特定时刻卡住了。下面是我的 .gitlab-ci.yml
文件:
image: "ruby:2.6"
before_script:
- ruby -v
- apt-get update -qy
- apt-get install -y nodejs
- apt-get install -y yarn
- yarn --version
- bundle install --path /cache
- bundle exec rails webpacker:install
test:
script:
- bundle exec rake db:create RAILS_ENV=test
- bundle exec rake test
CI 输出无错误地进行,直到它达到 $ bundle exec rails webpacker:install
。任务中止并显示此消息:
$ bundle exec rails webpacker:install
rails aborted!
ArgumentError: Malformed version number string 0.32+git
/builds/kvinklly/sample-app/bin/rails:5:in `<top (required)>'
/builds/kvinklly/sample-app/bin/spring:8:in `require'
/builds/kvinklly/sample-app/bin/spring:8:in `block in <top (required)>'
/builds/kvinklly/sample-app/bin/spring:5:in `tap'
/builds/kvinklly/sample-app/bin/spring:5:in `<top (required)>'
Tasks: TOP => webpacker:install => webpacker:check_yarn
(See full trace by running task with --trace)
我注意到 0.32+git 值很可能是安装的 yarn 版本,并验证了该版本:
$ yarn --version
0.32+git
有没有办法在 gitlab 上的 CI 脚本中指定较新版本或最新版本的 yarn?
我可以 post gemfile,但它是一个相当基本的 rails 应用程序,此时没有添加太多内容。
我使用以下方法让它工作:
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/ruby/tags/
image: "ruby:2.6"
# This is a basic example for a gem or script which doesn't use
# services such as redis or postgres
before_script:
- ruby -v # Print out ruby version for debugging
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
- apt-get update -qy
- apt-get install -y nodejs
- apt-get install -y yarn
- yarn install --check-files
- bundle install --path /cache # Install dependencies into ./vendor/ruby
- bundle exec rake webpacker:install
test:
stage: test
script:
- bundle exec rake db:create RAILS_ENV=test
- bundle exec rake test