Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Travis CI: branch filters in build matrix items

Tags:

travis-ci

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.

like image 497
tamasf Avatar asked Nov 08 '22 19:11

tamasf


1 Answers

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
like image 158
b3n Avatar answered Dec 24 '22 14:12

b3n