CI run step or CD shell script step is being marked as success even if there are errors in the command execution in the script

As part of the shell script step or run step in CD or CI stage, the commands will continue to process through the script even if a command within the script has failed. This behaviour can be changed by using the command “set” with the appropriate options as described here

The CI run step or CD shell script step would mark itself as failed or success depends on the exit code of the script that we run. With the use of “set -e” on top of the script, the step would be marked as failed if any command within the script return a non-zero status code.

We used to have multiple instances where the run step or shell script step would be marked as success even after using the command “set -e” on top of the script and if there were errors while execution a specific command in the script.

To confirm the reson why we mark a step as succeesul though there were errors as part of a specific command execution, you can use the basic linux command “echo $?” after a the command which will print the exit status of the last command that was run.

1 Like