构建阶段:使用 YAML 别名定义步骤

此示例有 3 个构建阶段

  • 两个作业,分别针对 Ruby 2.2 和 2.3 运行测试
  • 一个作业部署到预发布环境
  • 三个作业,分别针对预发布环境运行测试

以下是 .travis.yml 配置可能的样子

rvm:
  - 2.2
  - 2.3

script: bundle exec rspec

jobs:
  include:
    - stage: deploy to staging
      rvm: 2.3
      install: skip # bundle install is not required
      script: ./deploy.sh
    - &test-staging
      stage: test staging
      rvm: 2.3
      install: skip
      script: ./test-staging.sh one
    - <<: *test-staging
      script: ./test-staging.sh two
    - <<: *test-staging
      script: ./test-staging.sh three

以下是构建矩阵可能的样子

image

您可以在我们的 演示存储库 中找到此示例的代码