I don't understand travis "if"

I have read the travis documentation on the “if” statement four times and I still have no idea what the if is conditionally allowing or disallowing.

What I want to do is not run my tests on a pull request. Can anyone give me guidance on how to (not) do this? Thanks!

Hey there,

If you would like to run a job when your build request doesn’t belong to the pull request, you can use the following if statement.

if: type NOT IN (pull_request)

I hope that helps,

Travis CI Staff

No Mustafa I still don’t understand the syntax of if statements, specifically how the if relates to what is run when the condition is true. In pseudocode, what I want to do is:

if not pull request:
make all_tests

Can you explain how to do that in Yaml?


When you define the if statement within your .travis.yml or the multiple jobs specified in the same .travis.yml, the system checks if the condition is met, if so it is running the all relevant build steps that belong to the specific job.

I hope that clarifies.

No that doesn’t clarify. I would like to see what yaml i should write if I want to run this conditionally:

make all_tests

Where do I put the if statement?

You can simply add the if statement in the same level of hierarchy. Something like;

if: type NOT IN (pull_request)
 - make all_tests
 - some_other_command


That does not work, Mustafa: rather than just skipping the script: section, the build as a whole does not run.

Hey @gcallah,

Could you please share the full .travis.yml file that is not generated build?