【问题标题】:Using Multiple Operating Systems with Ruby and Shell in a Matrix with Travis CI在 Travis CI 的矩阵中使用带有 Ruby 和 Shell 的多个操作系统
【发布时间】:2019-06-21 23:47:11
【问题描述】:

我正在尝试创建一个 CI 测试,该测试使用多个 Ruby 版本在 Linux 上使用 rvm 执行测试,但我想在 Windows 上使用 bash shell 执行另一个测试。

我尝试了一些配置,但如果我在矩阵中有其他操作系统和语言,它们不允许我创建或使用多个 ruby​​ 版本。

例如,如果我使用以下配置,我将获得 3 个用于 Linux 不同 Ruby 版本的不同订单项:

os:
  - linux

dist: xenial
language: ruby
cache: bundler

rvm:
  - 2.4.5
  - 2.5.4
  - 2.6.2

script:
  - ruby -v

如果我添加一个矩阵并包含不同的操作系统和语言,我只会在矩阵中得到 2 个行项——一个用于 Linux(ruby),一个用于 Windows(shell)。 Windows 操作系统运行良好,但 Linux 只执行 rvm 列表中的第一个 ruby​​ 版本。

matrix:
  include:
    - os: linux
      dist: xenial
      language: ruby
      cache: bundler
      rvm: 
        - 2.4.5
        - 2.5.4
        - 2.6.2
      script:
        - ruby -v
    - os: windows
      language: shell
      script:
        - powershell -Command Write-Host Test

我想为 Linux 列出 3 个具有不同 ruby​​ 版本的构建作业,但在 Windows 上只有一个 shell 构建作业。是否可以通过 Travis CI 在具有多个操作系统和语言的矩阵中使用 rvm?

【问题讨论】:

    标签: ruby linux windows rvm travis-ci


    【解决方案1】:

    您必须为每个构建作业定义一个 include 块:

    matrix:
      include:
        - os: linux
          dist: xenial
          language: ruby
          cache: bundler
          rvm: 2.4.5
          script:
            - ruby -v
        - os: linux
          dist: xenial
          language: ruby
          cache: bundler
          rvm: 2.5.4
          script:
            - ruby -v
        - os: linux
          dist: xenial
          language: ruby
          cache: bundler
          rvm: 2.6.2
          script:
            - ruby -v
        - os: windows
          language: shell
          script:
            - powershell -Command Write-Host Test
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-27
      • 2016-07-23
      • 2021-08-26
      • 1970-01-01
      • 2014-04-17
      • 1970-01-01
      相关资源
      最近更新 更多