Marcel Stör
Marcel Stör

Reputation: 23565

How to use .travis.yml to cancel a Travis build

For a project certain preconditions have to met before a CI build makes sense. Not all of them can be ensured prior to commit. Hence, to safe resources I'd like to evaluate those preconditions in .travis.yml (i.e. using shell commands) and cancel the Travis build if not met.

I don't think it'd be helpful or feasible to start experimenting with kill variations in the before_install phase. There must be a better way.

Upvotes: 2

Views: 924

Answers (1)

tripleee
tripleee

Reputation: 189809

Put these checks in your regular install commands and have them exit with a failure if the preconditions are not met.

install:
   - check_preconditions && actually_build

This will result in "failed" builds whenever this happens. A (slightly silly) workaround is to abort with success, which instead will show a "successful" build even when nothing was actually built.

install:
  - { check_preconditions && actually_build; true; }

Upvotes: 2

Related Questions