GitLab CI/CD default: Keyword Global Job Config Prompt
Consolidate repeated per-job settings (image, retry, timeout, tags, hooks) into a single default: block so every job inherits sane behavior and your .gitlab-ci.yml stops repeating itself.
- Target user
- Platform engineers refactoring sprawling .gitlab-ci.yml files
- Difficulty
- Beginner
- Tools
- Claude, ChatGPT
The prompt
You are a GitLab CI/CD reviewer who has untangled hundreds of copy-pasted pipeline files into clean, DRY configurations using the `default:` keyword. I will provide: - My current `.gitlab-ci.yml` - Which settings are repeated across most jobs (image, tags, retry, timeout, before_script) - Any jobs that are deliberately different (their exceptions) Your job: 1. **Identify the global baseline** — scan every job and find the settings that 80%+ of jobs share. These are the candidates for `default:`. Call out the keywords that are actually allowed in `default:` (image, services, before_script, after_script, hooks, tags, cache, retry, timeout, interruptible, artifacts, id_tokens) versus ones that are NOT and must stay per-job (script, stage, rules, needs). 2. **Build the `default:` block** — produce a single top-level `default:` with the consolidated values. Set an opinionated baseline: pin an `image` digest, `retry` only on `runner_system_failure` and `stuck_or_timeout_failure` (NOT on script failures), a sane `timeout`, and `interruptible: true` so redundant pipelines auto-cancel. 3. **Handle the exceptions** — for jobs that diverge, show how per-job keys override the default, and how `inherit:default: false` or `inherit:default: [image, tags]` selectively opts out. Flag any job silently relying on a default it shouldn't. 4. **Hooks vs before_script** — recommend `hooks:pre_get_sources_script` for clone-time setup and reserve `before_script` for runtime prep; explain the ordering trap when both default and job define `before_script` (job replaces, does not append). 5. **Show the diff** — output the before/after line count and exactly which jobs got shorter. 6. **Validate** — give me a `gitlab-ci lint` invocation (API or `glab`) to confirm the refactor produces an identical job graph, plus a checklist of behaviors to spot-check (does the retry still fire, did any job lose its image). Output: (a) the refactored `.gitlab-ci.yml` with the `default:` block, (b) a table of what moved and what stayed, (c) the override/opt-out examples, (d) the validation commands. Bias toward: removing repetition without changing behavior, and never globally retrying script failures.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
GitLab CI/CD inherit: Keyword Variable & Default Control Prompt
Use the inherit: keyword to precisely control which global variables and default: settings a job receives, eliminating leaked env vars and surprise image/before_script inheritance.
-
GitLab CI/CD .gitlab-ci.yml Lint & Pre-Merge Validation Gate Prompt
Build a self-validating pipeline that lints its own .gitlab-ci.yml (CI Lint API), checks merged YAML and includes, and blocks broken pipeline config before it ever runs.
-
GitLab CI/CD extends, YAML Anchors & !reference Prompt
Refactor a sprawling .gitlab-ci.yml using extends:, hidden .jobs, YAML anchors, and the !reference tag to kill duplication while keeping the pipeline readable and debuggable.
-
GitLab CI/CD k6 Load Test Performance Gate Prompt
Design a .gitlab-ci.yml stage that runs k6 load/performance tests against a review or staging environment, enforces threshold-based pass/fail gates, and surfaces results as artifacts and metrics reports in merge requests.
More GitLab CI/CD prompts & error guides
Browse every GitLab CI/CD prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.