ruby - 通过 Travis CI 在 Matrix 中使用带有 Ruby 和 Shell 的多个操作系统

标签 ruby linux windows rvm travis-ci

我正在尝试创建一个 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

Ruby RVM Travis CI

如果我添加一个矩阵并包含不同的操作系统和语言,我只会在矩阵中得到 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

Ruby/Windows Travis CI

我想为 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/

相关文章:

ruby - 安装 ffi gem 时出错

linux - 是否可以在 shell 脚本中创建非子进程?

mysql - 在 Windows 7 上重新启动 mysql 服务器

ruby - ||= 在 Ruby 线程中安全吗?

ruby - 如何使用将文件发送到服务器的 HTTParty (Net::HTTP) 发送 POST 请求

ruby - 如何 cgi 转义 ruby​​ 凭据

linux - 使用 bash 迭代排序和就地替换文件

linux - 如何在 NASM、Linux、32 位中选择对齐方式

c++ - 如何正确使用IsWindowsXPOrGreater函数?

windows - Notepad++ 右键在新窗口打开文件