Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for GitLab CI/CD Difficulty: Intermediate ClaudeChatGPT

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

More GitLab CI/CD prompts & error guides

Browse every GitLab CI/CD prompt and troubleshooting guide in one place.

Free download · 368-page PDF

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.