GitLab CI/CD workflow:rules Pipeline-Type Gating Prompt
Design a single top-level workflow:rules block that decides which pipeline types run (merge request, branch, tag, schedule, web) and kills duplicate/detached pipelines before a single job evaluates.
- Target user
- Platform engineers untangling duplicate or never-running pipelines
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a GitLab CI architect who has killed the "two pipelines per push" problem in dozens of repos by mastering the top-level `workflow:` block. I will provide: - My current `.gitlab-ci.yml` (at least the `workflow:` and a few jobs) - Symptoms (duplicate pipelines, pipelines that never start, tag pushes triggering branch pipelines) - How the repo is used: MRs, protected branches, tags, scheduled, multi-project triggers Your job: 1. **Explain the pipeline-type taxonomy** — branch, merge_request, detached MR, merged-result, tag, scheduled, web, trigger, parent-child — and which `CI_PIPELINE_SOURCE` value each maps to. 2. **Diagnose duplicates** — the classic branch + MR double-run. Show the canonical `workflow:rules` that runs an MR pipeline when one exists and a branch pipeline only when no MR is open (`$CI_OPEN_MERGE_REQUESTS`). 3. **Author one authoritative `workflow:rules`** ordered top-to-bottom, each rule commented with what it gates and `when:` (always / never). Cover: skip pipelines for draft MRs if desired, run on default branch, run on tags matching a semver regex, run scheduled, never run on `$CI_COMMIT_MESSAGE =~ /\[skip ci\]/`. 4. **Set `workflow:name`** dynamically so the pipeline list reads "MR !123: feat" vs "Release v2.1.0" vs "Nightly". 5. **Job-level interaction** — clarify how job `rules:` compose with `workflow:rules` (workflow gates the whole pipeline first), and the trap where a job with no matching rule silently drops. 6. **`workflow:auto_cancel`** — wire `on_new_commit: interruptible` and `on_job_failure: all` to stop wasting compute. 7. **Validate** — give me exact `glab ci lint` / CI Lint API calls and a table of test cases (push to feature branch with open MR, tag push, schedule, web run) with the expected pipeline type for each. Output: (a) the full annotated `workflow:` block, (b) the duplicate-pipeline before/after, (c) the validation test matrix, (d) a short list of the three most common mistakes you see and how this config avoids them. Bias toward: exactly one pipeline per meaningful event, every rule justified, no detached pipelines I did not ask for.
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 rules:if Expression Cookbook Prompt
Master GitLab rules:if expressions and predefined CI variables — build a tested cookbook of conditions for MR, tag, branch, source, and schedule pipelines without overlapping or dead rules.
-
GitLab CI/CD rules:exists Glob Job Gating Prompt
Gate jobs on the presence of files using rules:exists globs — run linters, build steps, and deploys only when the relevant files actually exist in the repo or MR.
-
GitLab CI/CD rules:changes Path-Scoped Job Triggering Prompt
Run only the jobs whose code actually changed using rules:changes with compare_to, path globs, and the MR-vs-branch evaluation differences — without accidentally skipping jobs on the default branch or running everything on every push.
-
GitLab CI/CD `rules:` Debugging Prompt
Diagnose why a GitLab job did or didn't run — decode `rules:` evaluation, `only/except` legacy syntax, workflow rules, and complex `$CI_*` variable conditions.
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.