Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

You need to be careful exiting 666:

cmp@cmp-dev:~$ bash --version
GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Here is an exit 666:

$ bash
$ exit 666
exit
$ echo $?
154

It wraps at 255:

$ bash 
$ exit 256
exit
$ echo $?
0

Stick with 255 and under (better the devil you know eh?)

share|improve this 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.