How to Set a Job Timeout in GitLab CI
GitLab caps a job with the timeout keyword using a human-readable duration like 30m or 1h 30m.
Set timeout: on a job to bound its runtime. It must be below the runner timeout, which itself overrides the project-level default.
Per-job timeout
This job is killed if it runs longer than 30 minutes, regardless of the project default.
.gitlab-ci.yml
test:
timeout: 30m
script:
- npm ci
- npm test
e2e:
timeout: 1h 30m
script:
- npm run test:e2eGotchas
- The effective limit is the smallest of job
timeout, runner timeout, and project timeout - a jobtimeoutlarger than the runner timeout is ignored. - Durations are human-readable (
30m,1h,3h 30m), not seconds. - A timed-out job fails; use it as a safety net so a hung job does not occupy a runner indefinitely.
Related guides
How to Set a Job Timeout in GitHub ActionsSet a timeout in GitHub Actions with timeout-minutes at the job and step level to kill hung jobs before they…
How to Retry a Failing Job in GitLab CIAutomatically retry a failing GitLab CI job with the retry keyword - set max attempts and scope retries to sp…