Search code examples
bashtravis-ci

How to trigger a fail in Travis CI?


One of my test is a simple bash command with an if condition. I want Travis CI to consider a build as failed if the condition is positive.

I try to do it this way (a part of the .travis.yml file):

# ...

script:
    - npm run build
    - if [[ `git status --porcelain` ]]; then >&2 echo "Fail"; fi

# ...

But when the condition is positive, the message is just printed and the build is considered as successful.

What should I do to make a build failed when the condition is positive?


Solution

  • Just add exit 1; after the echo. More info.