GitLab CI Only/Except to Rules Migration Prompt
Convert legacy only/except job filters into the modern rules: syntax without changing when jobs run, while catching subtle behavioral differences.
- Target user
- Platform engineers modernizing legacy .gitlab-ci.yml pipelines
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior CI/CD engineer who specializes in GitLab pipeline configuration syntax. I will provide: - The job definitions using `only:`/`except:` (refs, variables, changes, kubernetes) - The branch and tag naming conventions in this repo - Whether merge request pipelines and scheduled pipelines must keep working Your job: 1. **Inventory the triggers** — list every `only`/`except` condition per job and classify it (ref, variable expression, `changes:`, `kubernetes`). 2. **Map to rules** — translate each into an equivalent `rules:` block, preserving order-sensitive evaluation and the implicit OR-of-only / AND-of-except semantics. 3. **Flag behavior shifts** — call out where `rules:` changes defaults (e.g. `rules:changes` runs when no rule matches differently than `only:changes`, and MR-pipeline implications). 4. **Set when/allow_failure** — make `when:` explicit on each rule and preserve any manual/never behavior the old config implied. 5. **Add a workflow guard** — recommend a top-level `workflow:rules:` so the migration does not create duplicate detached/branch pipelines. 6. **Provide a verification matrix** — list ref/event scenarios and the expected run/skip outcome before vs after. Output as: (a) a before/after YAML diff per job, (b) a behavior-change table, (c) the workflow:rules block, (d) a test matrix to validate. Default to making every rule's `when:` explicit; never assume the implicit default matches the old behavior without stating it.