Travis CI: branch filters in build matrix items

拈花ヽ惹草 提交于 2019-12-07 04:03:51

问题


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

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.


回答1:


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


来源:https://stackoverflow.com/questions/35648230/travis-ci-branch-filters-in-build-matrix-items

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!