Travis CI:构建矩阵项中的分支过滤器 [英] Travis CI: branch filters in build matrix items

查看:36
本文介绍了Travis CI:构建矩阵项中的分支过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

We are wondering whether there is any way to add filters to Travis matrix items. In our particular case, we wish to run certain jobs only on specific branches.

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

The following example would be an ideal way for configuring this scenario, however it doesn't seem to work:

matrix:
  include:
    - env: BUILD_TYPE=release
      branches:
        only:
          - master
    - env: BUILD_TYPE=ci
      branches:
        only:
          - develop

作为一种变通方法,我们可以通过检查适当的环境变量 (TRAVIS_BRANCH) 立即退出构建脚本,但这远非理想,因为启动从机和克隆 repo 需要相当长的时间.

As a workaround, we can exit from the build script immediately by checking the appropriate env vars (TRAVIS_BRANCH), but it is very far from ideal as launching the slave machine and cloning the repo takes a considerable amount of time.

推荐答案

您现在可以使用测试版功能条件构建阶段

You can now achieve this with the beta feature Conditional Build Stages

jobs:
  include:
    - stage: release
      if: branch = master
      env: BUILD_TYPE=release
    - stage: ci
      if: branch = develop
      env: BUILD_TYPE=ci

这篇关于Travis CI:构建矩阵项中的分支过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆