This seems very basic but I can't find it anywhere in the docs. I'm working on a project where we run some tests through a shell script wrapper like:
./foo.sh a
./foo.sh b
./foo.sh c
foo.sh
does not output XUnit format, so we need a different way to signal failure to CircleCI. Is exit 1
(or any nonzero exit code) recognized as a failure? What conditions cause CircleCI to report a step as having failed?
A non-zero exit status indicates failure. This seemingly counter-intuitive scheme is used so there is one well-defined way to indicate success and a variety of ways to indicate various failure modes. When a command terminates on a fatal signal whose number is N , Bash uses the value 128+ N as the exit status.
Knowing the exit code can be a valuable tool for determining why a program failed during the debugging process. In larger programs, which may include many instances of error checking and input validation, the pro- gram may return a different exit code for each error.
Shell scripts typically execute commands and capture their exit statuses. For the shell's purposes, a command which exits with a zero exit status has succeeded. A nonzero exit status indicates failure.
Extracting the elusive exit code To display the exit code for the last command you ran on the command line, use the following command: $ echo $? The displayed response contains no pomp or circumstance. It's simply a number.
Yes, CircleCI fails the build if any command, whether it runs tests or not, exits with a non-zero exit code. Documented here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With