GitLab CI "ERROR: Job failed: exit code 1" in CI
A command in your script (or before_script) exited non-zero, so the runner stops and reports "exit code 1". This is an application/test failure, not a runner fault: the line just above the error shows what actually failed.
What this error means
The job ends with "ERROR: Job failed: exit code 1" right after a failing command, with the command's own output printed just above.
$ pytest
... 1 failed, 12 passed in 3.40s
ERROR: Job failed: exit code 1Common causes
A test or build command genuinely failed
Tests failed, a linter found violations, or a build step errored; that non-zero exit propagates as exit code 1.
A command in a chained script failed silently
In a multi-command script, an earlier command failed; with default shell behavior the job stops at the first non-zero exit.
How to fix it
Read the command output above the error
- Scroll up to the last command before "exit code 1".
- Fix the underlying failure (test, lint, build) it reports.
- Re-run the job.
test:
script:
- set -e
- pytest -qAllow failure only when intended
If a non-blocking job may fail, mark it allow_failure rather than masking the real error elsewhere.
lint:
script: ruff check .
allow_failure: trueHow to prevent it
- Run the same commands locally before pushing.
- Use
set -eso multi-command scripts stop at the first failure. - Reserve
allow_failurefor genuinely non-blocking jobs.