Description

This control ensures that pull requests cannot be merged until they have received the required number of approvals from authorized reviewers. The review process helps validate code quality, security, and compliance with organizational standards before changes are integrated into protected branches.

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 review approvals before merging pull requests enforces peer review and segregation of duties, reducing the risk of introducing defects, security vulnerabilities, or unauthorized changes into critical code repositories. It also promotes accountability, collaboration, and knowledge sharing among development teams.

Impact

  • May increase the time required to complete pull request reviews and merges.

  • Improves code quality, maintainability, and security.

  • Supports organizational change management and compliance requirements.

Default Value

Disabled by default. Repository administrators must explicitly configure branch restrictions to require pull request approvals before merging.

Pre-Requisites

  • Administrative access to the repository

  • An existing Bitbucket repository

Test Plan

  1. Sign in to Bitbucket at https://bitbucket.org.

  2. Navigate to the target Bitbucket repository.

  3. Create a pull request against a branch protected by the branch restriction.

  4. Attempt to merge the pull request without obtaining the required approval(s).

  5. Obtain the required approval(s) from an authorized reviewer.

  6. Attempt to merge the pull request again.

  7. Verify that the Minimum number of approvals merge check is configured and enforced.

  8. If the approval requirement is not configured or enforced, follow the Implementation Steps to remediate the issue and repeat the test.

Implementation Steps

  1. Sign in to Bitbucket at https://bitbucket.org.

  2. Navigate to the target repository.

  3. Click the three-dot menu (⋯) next to the repository name and select Settings.

  1. Under Workflow, select Branch restrictions.

  1. Click Add a branch restriction or edit an existing branch restriction.

  1. Under Select branches, specify the branch name, branch pattern, or branch type to protect.

  2. Select the Merge settings tab.

  3. Under Merge checks, enable Minimum number of approvals.

  4. Specify the minimum number of required approvals according to organizational policy.

  1. Click Save to apply the branch restriction.

Backout Plan

  1. Sign in to Bitbucket at 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. Select the Merge settings tab.

  1. Click Save to apply the updated configuration.

Reference