DevOps / GitLab CI Basics Interview Questions
What is the 'timeout' keyword in GitLab CI and what are the defaults?
The timeout keyword sets the maximum duration a job is allowed to run before GitLab forcefully stops it. Timeouts prevent hanging jobs from blocking runners and consuming resources indefinitely.
# Job-level timeout long-running-test: script: - run-full-integration-tests.sh timeout: 2 hours # stop after 2 hours build-job: script: - make build timeout: 30 minutes # stop after 30 minutes # Timeout format examples: # timeout: 3600 (seconds) # timeout: 60 minutes # timeout: 2 hours # timeout: 1h 30m # timeout: 1 day # Default timeout hierarchy: # 1. Job-level timeout (if set) # 2. Project-level timeout (Settings > CI/CD > General pipelines) # 3. Runner timeout (set when runner is registered) # The smallest of project timeout and runner timeout applies, # then job-level timeout can only be lower than that
| Level | Where set | Default |
|---|---|---|
| Job | timeout: keyword in job | No default (uses project or runner) |
| Project | Settings > CI/CD > General pipelines | 60 minutes |
| Runner | Registered runner config | No limit (unlimited) |
Key rule: a job timeout cannot exceed the project-level timeout or the runner's maximum timeout. If you set a job timeout longer than the project timeout, the project timeout wins.
More Related questions...