Azure Pipelines "Bash exited with code 1"
A Bash/script step ran a command that exited non-zero, and Azure failed the step. Bash exited with code 1 is the wrapper error - the genuine failure is in the command output just above it.
What this error means
A Bash@3 or script: step ends with ##[error]Bash exited with code 1. The step’s own logs show the failing command (a failed test, a missing file, a non-zero tool exit) immediately before this line.
npm ERR! Test failed. See above for more details.
##[error]Bash exited with code '1'.Common causes
A command in the script genuinely failed
Bash uses the last command’s exit code (and Azure adds set -e semantics) so any non-zero command - a failing test, lint, or build - fails the whole step.
Failures masked by a pipe or subshell
Without pipefail, a failure on the left of a pipe is hidden by a succeeding command on the right, so the real cause can be earlier than the reported line suggests.
How to fix it
Read the command output above the error
The exit-code line is a symptom. Scroll up to the first real error - that is what to fix.
Make failures explicit and visible
Turn on strict flags so the failing command is the one that fails the step.
steps:
- bash: |
set -euo pipefail
npm testHow to prevent it
- Use
set -euo pipefailin multi-line Bash steps. - Keep steps small so the failing command is obvious.
- Surface tool logs (test reports, lint output) as pipeline artifacts.