Travis CI:构建矩阵项中的分支过滤器

tam*_*asf 5 travis-ci

我们想知道是否有任何方法可以为Travis矩阵项添加过滤器.在我们的特定情况下,我们希望仅在特定分支上运行某些作业.

以下示例将是配置此方案的理想方法,但它似乎不起作用:

matrix:
  include:
    - env: BUILD_TYPE=release
      branches:
        only:
          - master
    - env: BUILD_TYPE=ci
      branches:
        only:
          - develop
Run Code Online (Sandbox Code Playgroud)

作为一种解决方法,我们可以通过检查相应的env vars(TRAVIS_BRANCH)立即退出构建脚本,但它远非理想,因为启动从机并克隆repo需要相当长的时间.

b3n*_*b3n 2

您现在可以使用测试版功能“条件构建阶段”来实现此目标

jobs:
  include:
    - stage: release
      if: branch = master
      env: BUILD_TYPE=release
    - stage: ci
      if: branch = develop
      env: BUILD_TYPE=ci
Run Code Online (Sandbox Code Playgroud)