# Ensure CI pipeline passes before merge

- Source: https://support.icompaas.com/support/solutions/articles/a_1789072807552386-ensure-ci-pipeline-passes-before-merge
- Section: [Solutions](https://support.icompaas.com/support/solutions) › [Version Control System (VCS)](https://support.icompaas.com/support/solutions/c_1781179095087930) › [Bitbucket](https://support.icompaas.com/support/solutions/folders/f_1781179159125832)
- Last updated: 2026-10-26
- Publisher: iCompaas, Inc. (https://www.icompaas.com)

Description

This control ensures that pull 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.

Note: Only repository-level branch restrictions are detected. Restrictions set only at the project level are not returned by Bitbucket’s API and will result in a FAIL. Configure the restriction at the repository level for accurate results.

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

-   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 CI pipeline checks complete.
    

Default Value

Disabled by default. Repository administrators must explicitly configure branch restrictions to require successful build or pipeline checks before pull requests can be merged.

Pre-Requisites

-   Administrative access to the repository
    
-   An existing Bitbucket repository
    

Test Plan

1.  Sign in to Bitbucket at [https://bitbucket.org](https://bitbucket.org/).
    
2.  Navigate to the target Bitbucket repository.
    
3.  Verify that Bitbucket Pipelines is enabled, or an external CI tool is integrated and posting build statuses.
    
4.  Verify that a branch restriction is configured for the protected branch.
    
5.  Verify that "Minimum number of successful builds for the last commit with no failed builds and no in progress builds" is enabled, with value ≥ 1.
    
6.  If CI is not connected, the check is not enabled, or the value is 0, follow the Implementation Steps to remediate and repeat the test.
    
7.  Create a test PR, attempt merge while the build is failing/running — verify it's blocked.
    
8.  Let the build pass, attempt merge again — verify it succeeds. Delete the test PR/branch afterward.
    

Implementation Steps

1.  Sign in to Bitbucket at [https://bitbucket.org](https://bitbucket.org/).
    
2.  Navigate to the target repository.
    
3.  Click the three-dot menu (⋯) next to the repository name and select Settings.
    

4.  Under Workflow, select Branch restrictions.
    

5.  Click Add a branch restriction or edit an existing branch restriction.
    
6.  In the branch Restriction, select by branch name or pattern add “\*” value (it will include all branches).
    

7.  Select the Merge settings tab.
    
8.  Enable Minimum number of successful builds for the last commit with no failed builds and no in progress builds.
    
9.  Specify the minimum number of successful builds required (typically 1 or greater according to organizational policy).
    

10.  Click Save to apply the branch restriction.
     

Backout Plan

1.  Sign in to Bitbucket at [https://bitbucket.org](https://bitbucket.org/).
    
2.  Navigate to the target repository.
    
3.  Click the three-dot menu (⋯) next to the repository name and select Settings.
    
4.  Under Workflow, select Branch restrictions.
    
5.  Edit the applicable branch restriction.
    
6.  Disable Minimum number of successful builds for the last commit with no failed builds and no in progress builds.
    
7.  Click Save.
    

Reference

-   [https://support.atlassian.com/bitbucket-cloud/docs/use-branch-permissions/](https://support.atlassian.com/bitbucket-cloud/docs/use-branch-permissions/)
    
-   [https://support.atlassian.com/bitbucket-cloud/docs/checks-for-merging-pull-requests/](https://support.atlassian.com/bitbucket-cloud/docs/checks-for-merging-pull-requests/)

## Related compliance guidance

- [SOC 2 compliance: a practical implementation guide for cloud-native SaaS teams](https://support.icompaas.com/compliance/soc-2-trust-services-criteria): Configuration checks like this one are the technical half of a SOC 2 / ISO 27001 programme — the guide shows where they fit, what else an auditor expects, and how to evidence them.
- [ISO/IEC 27001:2022 compliance: a practical implementation guide](https://support.icompaas.com/compliance/iso-27001-2022): ISO 27001 Annex A.8 (technological controls) is where cloud hardening evidence lands; the guide shows how to run the ISMS around it.
