require-gitlab-ci-merge-request-pipelines
Require explicit merge-request pipeline configuration in .gitlab-ci.yml.
Targeted pattern scopeâ
This rule checks .gitlab-ci.yml (or .gitlab-ci.yaml) for merge-request pipeline signals, including:
rulesorworkflow: rulesusingmerge_request_eventonly: [merge_requests]-style clauses
What this rule reportsâ
This rule reports GitLab CI configurations that do not explicitly enable merge-request pipeline behavior.
Why this rule existsâ
GitLab documents merge-request pipelines as event-driven (CI_PIPELINE_SOURCE == "merge_request_event") and expects matching job or workflow rules in .gitlab-ci.yml. Explicit MR pipeline configuration helps ensure pre-merge validation runs consistently.
â Incorrectâ
// .gitlab-ci.yml
stages:
- test
test:
stage: test
script:
- npm test
â Correctâ
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
test:
script:
- npm test
test:
script:
- npm test
only:
- merge_requests
ESLint flat config exampleâ
import repoPlugin from "eslint-plugin-repo";
export default [
repoPlugin.configs.gitlab,
{
plugins: { "repo-compliance": repoPlugin },
rules: {
"repo-compliance/require-gitlab-ci-merge-request-pipelines": "error",
},
},
];
When not to use itâ
Disable this rule only if merge-request validation is guaranteed by an external pipeline architecture and repository-level .gitlab-ci.yml intentionally excludes MR-specific logic.
Rule catalog ID: R025
Further readingâ
Adoption resourcesâ
- Enable this rule together with
require-gitlab-ci-security-scanningto enforce both security and MR-quality signals in GitLab CI.