POC: Solve duplicate MR pipelines

What does this MR do and why?

POC: Add prevent_duplicate_mr_pipelines project setting

When pushing to a branch with an open merge request, GitLab creates both a branch pipeline and a merge request pipeline. This causes confusion, wastes CI/CD resources, and creates compliance gaps.

Add a new opt-in project setting prevent_duplicate_mr_pipelines.

When enabled:

  • The branch pipeline is suppressed at BaseHooksService#create_pipeline? before any CI config parsing or Sidekiq job is enqueued.
  • The implicit only: [branches, tags] default is stripped from jobs without explicit rules/only/except, so they are included in merge request pipelines.
  • Only push-triggered pipelines are affected. Manual, API, scheduled, and triggered pipelines are unaffected.

References

Create at most 1 pipeline when in the context o... (gitlab-org#6044)

How to set up and validate locally

  1. Create an invalid CI Config to a project

Screenshot_2026-05-25_at_16.45.24

  1. Create an MR with some changes

Screenshot_2026-05-25_at_16.45.48

  1. See the duplicate pipelines

Screenshot_2026-05-25_at_16.46.03

  1. Make another change on the MR branch

Screenshot_2026-05-25_at_16.46.19

  1. See the duplicate pipelines again

Screenshot_2026-05-25_at_16.46.31

  1. Enable the setting

Screenshot_2026-05-25_at_17.09.19

  1. Make another change on the MR branch

Screenshot_2026-05-25_at_17.09.42

  1. See no duplicate pipelines

Screenshot_2026-05-25_at_17.10.01

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading
Loading