Kiran
Kiran

Reputation: 57999

Building branches/commits on demand in Travis CI

I would like to achieve the following setup in Travis CI.

  1. Do a build whenever commits are pushed to dev or release branches only.

  2. Disable builds whenever commits are pushed to any other branch apart from dev or release but build pull requests.

  3. If a developer is really interested to know if his commits are good, then he should be able to kick start a build on Travis CI explicitly by choosing a branch/commit.

From reading the documentation on Travis CI and some blog posts, I see that I can achieve "1." and "2."

Does anyone know how to make "3." work?

Update-1:
The reason I want scenario "3." is because the developers in our team (or in general any other team) make several commits and push them even before they send out a pull request. Building for every single commit of a private branch even before it goes for a pull request is causing lot of requests to queue up in the Travis CI queue which unnecessarily blocks developers who really care to verify a particular commit to check if everything is good or not before sending out a pull request.

Having the following is just fine for us:

Upvotes: 0

Views: 223

Answers (1)

localheinz
localheinz

Reputation: 9592

You can easily achieve 1 and 2 by whitelisting the branches you want to see push builds for:

branches:
  only:
    - dev
    - release

For reference, see https://docs.travis-ci.com/user/customizing-the-build/#Whitelisting-or-blacklisting-branches.

You can achieve 3 only if your developers open a PR against one of the whitelisted branches.

I'd personally recommend to open a PR as early as possible (after the first commit), as it makes work in progress visible to everyone who is interested.

Upvotes: 1

Related Questions