How to you add a command line test to Jenkins that reads the exit code

command-line-interfaceJenkinsscripting

I want to add a command line script to Jenkins as part of the build process. This command line script will exit with an error code of 0 if things where successful or 666 if it fails. I wish to stop the build if this script fails.

Is it possible to do this using Jenkins? If so how?

Best Answer

Your bash build script can set -e prior to running your test.

set -e will cause Jenkins to stop the build if there's a non-zero exit status during the build. You would have something like this in the Execute Shell box in the project configuration:

set -e
yourcommand1
yourcommand2

Here's some documentation on bash options.