如何配置travis以便特定的gemfile仅使用特定版本的ruby?

时间:2016-03-04 21:28:33

标签: ruby travis-ci

那么如何配置这个travis ci文件,以便rails5 gemfile只测试/使用ruby 2.2.2? Activesupport 5需要ruby 2.2.2。

language: ruby
env:
  - CI=true
before_script:
  - "bundle exec rake db:prepare"
rvm:
  - 2.0.0
  - 2.1.6
  - 2.2.2
gemfile:
  - gemfiles/rails32.gemfile
  - gemfiles/rails4.gemfile
  - gemfiles/rails41.gemfile
  - gemfiles/rails42.gemfile
  - gemfiles/rails5beta.gemfile
notifications:
  recipients:
    - someone@gmail.com
    - someone2@gmail.com

2 个答案:

答案 0 :(得分:3)

您可以像这样定义构建matrix

language: ruby
env:
  - CI=true
before_script:
  - "bundle exec rake db:prepare"
matrix:
  include:
    - rvm: 2.0.0
      gemfile:
        - gemfiles/rails32.gemfile
        - gemfiles/rails4.gemfile
        - gemfiles/rails41.gemfile
        - gemfiles/rails42.gemfile
    - rvm: 2.1.6
      gemfile:
        - gemfiles/rails32.gemfile
        - gemfiles/rails4.gemfile
        - gemfiles/rails41.gemfile
        - gemfiles/rails42.gemfile
    - rvm: 2.2.2
      gemfile:
        - gemfiles/rails32.gemfile
        - gemfiles/rails4.gemfile
        - gemfiles/rails41.gemfile
        - gemfiles/rails42.gemfile
        - gemfiles/rails5beta.gemfile
notifications:
  recipients:
    - someone@gmail.com
    - someone2@gmail.com

请参阅文档:Travis CI - Customizing the Build - Build Matrix

答案 1 :(得分:0)

找到答案 - 显然,Travis包含一个矩阵选项,允许您不使用特定的gemfile运行某些Ruby版本(或运行它们)

matrix:
    exclude:
    - rvm: 2.0.0
        gemfile: Gemfile
        env: DB=mongodb
    - rvm: 2.0.0
        gemfile: Gemfile
        env: DB=redis
    - rvm: 2.0.0
        gemfile: Gemfile
        env: DB=mysql