Pipelines run twice for merge request branches: a branch pipeline and an MR pipeline.
IntermediateScenarioGitLab CI
Answer
Situation read → Duplicate pipelines from overlapping triggers.
What I'd do →
- Use the recommended workflow rules:
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
- Confirm results with the pipeline source in the UI.
Why → Branch pipelines are suppressed when an MR is open, so only one pipeline runs.
Interview tip → Know CI_PIPELINE_SOURCE values.
More on GitLab CI
How does GitLab CI/CD work at a high level?BeginnerWhat is a GitLab Runner and what executors exist?IntermediateWhat are the types of runners (shared, group, project) and tags?IntermediateHow do `rules:` work and how do they replace `only/except`?IntermediateWhat are workflow rules and how do they prevent duplicate pipelines?AdvancedHow do artifacts and cache differ in GitLab CI?Intermediate