我正在尝试创建一个 CI 测试,该测试在 Linux 上使用 rvm 使用多个 Ruby 版本执行测试,但我想在 Windows 上使用 bash shell 执行另一个测试。
我尝试了一些配置,但如果矩阵中有其他操作系统和语言,它们不允许我创建或使用多个 ruby 版本。
例如,如果我使用以下配置,我会为具有不同 Ruby 版本的 Linux 获得 3 个不同的订单项:
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?
最佳答案
您必须为每个构建作业定义一个 include
block :
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
关于ruby - 通过 Travis CI 在 Matrix 中使用带有 Ruby 和 Shell 的多个操作系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56711529/