Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Exclude jobs based on branch name #7149

Closed
lmazuel opened this issue Jan 13, 2017 · 9 comments
Closed

Exclude jobs based on branch name #7149

lmazuel opened this issue Jan 13, 2017 · 9 comments

Comments

@lmazuel
Copy link

lmazuel commented Jan 13, 2017

Hello,

I'm sorry if this topic is covered somewhere in the documentation, I wasn't able to find an answer anywhere.

I want to exclude jobs from my matrix depending of the branch name.
For instance, let's say I have two Python jobs:

language: python
python:
  - "2.7"
  - "3.6"

I want to exclude "2.7" if branch names startswith "deploy", but do everything if not ("master", PRs, etc.).

Deployment framework already allows me to deploy only if "python" is "3.6", but the other job are still executed (for nothing, waste of time and resources).

I was looking for a way to declare that in "exclude" of "matrics" (of anywhere else to achieve the goal :))

Workaround tentative: is there a way to skip a job from a before_install step (so I can check $TRAVIS_TAG and exit)?

Thank you!

@fgregg
Copy link

fgregg commented Apr 11, 2017

matrix:
  - python: "3.6"
  - python: "2.7"
    before_install:
      - if ! [[ $TRAVIS_TAG ]]; then exit 0; fi

works to bail out early, but you still need to wait for the machine to be provisioned and the setup that happens before_install

@BanzaiMan
Copy link
Contributor

This feature is useful for Build Stages.

@nfantone
Copy link

nfantone commented May 18, 2017

Same requirement over here. We are building an Android .apk on a - language: android matrix and it takes several minutes for the environment to boot and startup before bailing thanks to - if [ -z "$TRAVIS_TAG" ]; then travis_terminate 0; fi;.

It'd be nice if it could be skipped altogether. Something like an on: clause for every include in the matrix, perhaps?

@felix-weizman-deel
Copy link

This feature is super useful for partial builds.

cohen990 pushed a commit to cohen990/EasyConfig.Net.Core that referenced this issue Jul 13, 2017
travis doesn't support running stages based on branch - see travis-ci/travis-ci#7149
@evan-scott-zocdoc
Copy link

it takes several minutes for the environment to boot and startup before bailing

Same issue on our side. The "deploy" job still has to boot up and run even for PR builds where we definitely do not want to deploy code.

@keradus
Copy link

keradus commented Aug 30, 2017

feature was already approved , more info at travis-ci/beta-features#11

andy-maier added a commit to zhmcclient/python-zhmcclient that referenced this issue Sep 4, 2017
Details:
- So far, some combinations in the build matrix were simply commented out.
  The idea was always to activate them again, when the Travis run is
  a cron-triggered run. However, Travis does not support conditionals
  in the build matrix definition. This change uses the before_install
  keyword on a build matrix item to exit if not in a cron-triggered run,
  on the matrix items that had been commented out so far. This trick
  is described in a response to Travis issue #7149
  travis-ci/travis-ci#7149
- Because more combinations are now active again, added a check for the
  operating system to the invocation of coveralls, in order to make sure
  that it is being invoked only once.

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
@BanzaiMan
Copy link
Contributor

While it is considered beta (some future changes are possible), our recent release of the Build Stages feature makes this possible. https://blog.travis-ci.com/2017-09-12-build-stages-order-and-conditions

In the use case of OP:

I want to exclude "2.7" if branch names startswith "deploy", but do everything if not ("master", PRs, etc.).

One can write:

language: python
python:
  - "3.6"
matrix:
  include:
    - python: "2.7"
      if: branch =~ ^deploy

@scottx611x
Copy link

@BanzaiMan I had success with your suggestion by flipping the order of the if

language: python
python:
  - "3.6"
matrix:
  include:
    - if: branch =~ ^deploy
      python: "2.7"

@stale
Copy link

stale bot commented Apr 13, 2018

Thanks for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please do feel free to either reopen this issue or open a new one. We'll gladly take a look again! You can read more here: https://blog.travis-ci.com/2018-03-09-closing-old-issues

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

8 participants