Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does CircleCI do with non-0 exit codes?

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?

like image 806
Patrick Collins Avatar asked Feb 02 '16 18:02

Patrick Collins


People also ask

What is a nonzero exit code?

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.

Why is exit code important?

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.

What is a zero exit status?

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.

How do you use exit codes?

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.


1 Answers

Yes, CircleCI fails the build if any command, whether it runs tests or not, exits with a non-zero exit code. Documented here.

like image 67
Dave Schweisguth Avatar answered Nov 10 '22 10:11

Dave Schweisguth