# GitLab CI: ERROR: Job failed: exit code 1

**Code:** `ERROR: Job failed: exit code 1` · **Category:** CI/CD · **Seen on:** GitLab CI

The last command in the job's `script` returned a non-zero status; the real error is printed earlier in the job log.

## Meaning

GitLab runs script lines in order and stops at the first failing command. Scroll up for the first red output. Exit code 127 means command not found, 126 not executable, 137 out of memory/killed. Reproduce locally in the same image to confirm.

## Common causes

- Tests, lint or build failing
- Command not found or not executable (127/126)
- Missing variable or file in the image
- Out-of-memory kill (137)
- Script `exit 1` on a failed check

## Quick fix

1. Read the log above the final line for the first error
2. Run the same image locally: `docker run --rm -it -v "$PWD":/w -w /w IMAGE sh`
3. Add `set -eu` and echo key variables

## Detailed fix by platform

### GitLab CI

1. Debug with `variables: CI_DEBUG_TRACE: "true"` (prints all commands; may expose secrets — use carefully)

## How to diagnose

1. **Log** — First error line?
2. **Image** — Same tool versions locally?
3. **Code** — Which exit code?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/cicd/gitlab-job-failed-exit-code-1)
