Skip travis build if certain condition is met

Is there any way to kill travis build process & exit with status 0 so it will be marked as succeeded? Basically what I’m trying to do here is skip the entire build pipeline if certain condition is met. That condition is, “if files in /abc directory change only then trigger travis else skip it”, so I am using git diff to check if files changed in the /abc directory. I checked there is an option in travis wherein if you include [skip ci] in your commit message then it skips the CI. But I cannot use that option because 90% of time I will be skipping the CI, that means 90% of the time I will have to add [skip ci] in commit messages which is quite cumbersome. Then I found that there is travis_terminate 0 command to kill travis process with zero status but it doesn’t work as expected (the build gets stuck even after executing that command). Is there any way I can achieve this? Basically skip the pipeline if certain condition is met

exit 0 will immediately stop the job with success. That’s because your commands are run with eval i.e. within the same shell process and exit will terminate that process.

Note however that tasks that normally run after your script (e.g. cache save) will not run.

I found it more useful to rather change my script logic so that the rest of it becomes a no-op (e.g. set a flag variable that is checked by further commands).

1 Like

Perfect, that solves the problem.