I am looking for how to run Travis conditionally by following conditions.
When at the pull-request, as a default behavior without branches syntax and without if syntax, the both “Travis CI - Branch” and "Travis - Pull Request ‘’ are executed. The following screen shot shows the status. But I want to enable only “Travis CI - Pull Request” excluding “Travis CI - Branch” build at the pull-request, because I want to see the result from https://travis-ci.com/github/<name>/<repo>/pull_requests.
I want to enable Travis when a commit is pushed or when it is executed on cron mode to specific branches such as master.
I want to enable Travis when a commit is pushed from any branches on the “forked” repository.
Do you have any idea how to implement this condition in .travis.yml?
Maybe we need to use if syntax on the top level.
Here is a related past discussion about this topic. However, the mentioned branches - only syntax does not cover my case, because it does not enable Travis at the push timing.
Here is one example possibly to avoid one of the duplicated builds on the pull-request timing. But in my case I want to enable Travis at the push to master branch. So, maybe I need a different condition.
The core challenge is how to distinguish the “Travis CI - Branch” build to master branch at the pull-request from another build by pushing a commit to master branch at push by a condition.
In Github project settings → Branches → Branch protection rules, disable the “Branch” status check.
Didn’t quite get that. In combination with the previous point, looks like you just want to run all the kinds of builds, but only for the branch master:
In Github project settings → Branches → Branch protection rules, disable the “Branch” status check.
The following testing repo to show the screen shot picture did not have the protected branches. So, I am not sure if it is related to excluding “Travis CI - Branch”.
Didn’t quite get that. In combination with the previous point, looks like you just want to run all the kinds of builds, but only for the branch master:
Yes, right for the all kind of builds. The actual case I am working on is the ruby/ruby repository. It’s not only master branch but also the master and ruby_N_N branches (version stable branches).
if: (repo = ruby/ruby AND (branch = master OR branch =~ /^ruby_\d_\d$/)) OR repo != ruby/ruby
Note on the following condition without repo = ruby/ruby AND, when sending a PR from forked repo’s master or ruby_N_N on a forked repository, the PR has 2 Travis builds (Travis CI - Pull-request, and Travis CI - Branch). So, I need to add the condition repo = ruby/ruby AND .
if: branch = master OR branch =~ /^ruby_\d_\d$/ OR repo != ruby/ruby
Thanks! It seems I could solve this issue with your help.