【问题标题】:gitlab CI - installing correct version of yarngitlab CI - 安装正确版本的纱线
【发布时间】:2021-04-28 03:17:00
【问题描述】:

我正在尝试使用 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 脚本期间指定更新版本或最新版本的纱线?

我可以发布 gemfile,但它是一个相当基本的 rails 应用程序,目前没有添加太多内容。

【问题讨论】:

标签: ruby-on-rails continuous-integration gitlab yarnpkg webpacker


【解决方案1】:

我使用以下方法让它工作:

# 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-09
    • 2018-08-10
    • 1970-01-01
    • 1970-01-01
    • 2019-08-23
    相关资源
    最近更新 更多