Skip to content
Latchkey

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.

GitLab Runner
$ pytest
... 1 failed, 12 passed in 3.40s
ERROR: Job failed: exit code 1

Common 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

  1. Scroll up to the last command before "exit code 1".
  2. Fix the underlying failure (test, lint, build) it reports.
  3. Re-run the job.
.gitlab-ci.yml
test:
  script:
    - set -e
    - pytest -q

Allow failure only when intended

If a non-blocking job may fail, mark it allow_failure rather than masking the real error elsewhere.

.gitlab-ci.yml
lint:
  script: ruff check .
  allow_failure: true

How to prevent it

  • Run the same commands locally before pushing.
  • Use set -e so multi-command scripts stop at the first failure.
  • Reserve allow_failure for genuinely non-blocking jobs.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →