Description:
This control ensures that merge requests cannot be merged into protected branches until the configured Continuous Integration (CI) pipeline has completed successfully. The CI pipeline validates code changes through automated build, test, and verification processes before integration.
Rationale:
Requiring a successful CI pipeline before merge helps prevent defective, unstable, or non-compliant code from being introduced into protected branches. Automated validation improves software quality, reduces deployment risks, and ensures that code changes meet organizational standards before being merged.
Impact:
Prevents merge requests from being merged when CI pipeline checks fail.
Improves code quality and software reliability.
Identifies build, test, and integration issues before code is merged.
Supports secure software development and change management requirements.
May increase merge times while the CI pipeline checks are complete.
Default Value:
Disabled by default. Project administrators must explicitly configure merge request settings to require successful CI pipeline execution before merge.
Remediation
Test Plan
Navigate to the target GitLab project.
Create a merge request against a protected branch.
Ensure the CI pipeline has not completed successfully or is in a failed state.
Attempt to merge the merge request.
Verify that the merge is blocked.
Run the CI pipeline and ensure it completes successfully.
Attempt to merge the merge request again.
Verify that the CI pipeline requirement is configured and enforced before merge.
If the CI pipeline requirement is not configured or enforced, follow the Implementation Steps to remediate the issue and repeat the test.
Implementation Steps:
Sign in to GitLab with Maintainer or Owner access to the project.
Navigate to the target project.
Create or verify the existence of a CI/CD pipeline using a .gitlab-ci.yml configuration file.
Execute the pipeline and verify that it runs successfully.
Under Settings, click Merge requests.
Under Merge checks, enable Pipelines must succeed.
Save the configuration changes.
Backout Plan:
Sign in to GitLab with Maintainer or Owner access to the project.
Navigate to the target project.
Select Settings → Merge requests.
Disable Pipelines must succeed.
Save the configuration changes.
References: