Founding prices until 15 December: 30% off Pro, locked for life. See pricing

$ … CI step passes even though the command failed

Why a CI step passes when a command failed: exit codes and pipes

A failure is swallowed by a pipe, by || true, or by a script that doesn't stop on errors.

CI/CD

What it means

CI marks a step failed only if it exits non-zero. In a pipe, only the last command's status counts (cmd | tee log hides cmd's failure); a script without set -e carries on after an error and exits with the last command's status.

Causes and fixes

Most likely first. Run the check, and if it matches, apply the fix.

1. A pipe hides the failing command's exit code

Check:

grep -n '|' the step

Fix: set -o pipefail (bash) at the top of the script.

2. The script keeps going after errors

Check:

head -3 script.sh

Fix: set -euo pipefail, and exit with a meaningful code.

3. The test or check prints FAIL but exits 0

Check:

run it locally and echo $?

Fix: Make it exit non-zero on failure.

Fix it yourself

A live machine in your browser with this problem already on it. The grader checks the result.

Open the lab

No account needed for your first tries.

Related errors