With the following entry the script will only be executed if it is not a PR and the branch is master.
after_success:
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" -a "$TRAVIS_BRANCH" = "master" ]; then bash doit.sh; fi'
It is not enough to evaluate TRAVIS_BRANCH
. TRAVIS_BRANCH
is set to master when a PR against master is created by a fork.
See also the description of TRAVIS_BRANCH
on https://docs.travis-ci.com/user/environment-variables/:
- for push builds, or builds not triggered by a pull request, this is the name of the branch
- for builds triggered by a pull request this is the name of the branch targeted by the pull request
- for builds triggered by a tag, this is the same as the name of the tag (
TRAVIS_TAG
)
If you work with tags you have to consider TRAVIS_TAG
as well. If TRAVIS_TAG
is set, TRAVIS_BRANCH
is set to the value of TRAVIS_TAG
.
after_success:
- if [ "$TRAVIS_PULL_REQUEST" = "false" -a \( "$TRAVIS_BRANCH" = "master" -o -n "$TRAVIS_TAG" \) ]; then doit.sh; fi