GitLab CI/CD Duplicate Branch + MR Pipeline Prevention Prompt
Stop the double-pipeline problem where both a branch pipeline and a merge request pipeline run for the same commit, wasting compute minutes.
- Target user
- Developers and CI maintainers tuning workflow rules
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior GitLab CI/CD engineer who specializes in pipeline trigger logic. I will provide: - My current `workflow:rules` block (or none) - Whether I use merge request pipelines, merged results pipelines, or merge trains - Examples of when I see two pipelines for one push - Which branches are protected / default Your job: 1. **Explain the cause** — clarify how `$CI_PIPELINE_SOURCE` values (`push`, `merge_request_event`, `web`) create the detached-vs-branch duplication. 2. **Author workflow:rules** — write a canonical `workflow:rules` block that runs an MR pipeline when one is open and a branch pipeline otherwise, using `$CI_OPEN_MERGE_REQUESTS` to suppress the redundant branch run. 3. **Tag pipeline naming** — add `workflow:name` so the pipeline list clearly labels pipeline type. 4. **Job-level guard** — show how `rules:if` on individual jobs should mirror the workflow gate to avoid jobs leaking into the wrong pipeline type. 5. **Edge cases** — handle tags, scheduled, and `web`-triggered pipelines explicitly. 6. **Verify** — describe how to test using a throwaway branch + MR and read the pipeline source in the UI. Output as: (a) the full `workflow:rules` + `workflow:name` block, (b) a before/after table of which pipelines fire per event, (c) a validation checklist. Note any rule that would accidentally block all pipelines, and give a one-line revert.
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 Conditional Deploy & Environment Rules Design Prompt
Design rules: and workflow: logic for environment-aware deploys so the right job runs per branch, tag, and trigger source — auto-deploy to staging, manual gate to prod, skip on docs-only changes — without duplicate or stuck pipelines.
-
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.
-
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.
-
GitLab CI/CD before_script to extends Refactor Prompt
Refactor sprawling, duplicated before_script and inline shell across jobs into reusable hidden jobs, extends, and !reference so setup logic is defined once, tested, and consistent across the pipeline.
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.