Description

This check verifies that Bitbucket repositories are configured to automatically delete source branches after a pull request is successfully merged. Enabling automatic branch deletion helps maintain repository cleanliness by removing temporary feature or development branches that are no longer required after changes are integrated into the target branch.

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

Merged branches that remain in a repository can accumulate over time, creating unnecessary clutter and making branch management more difficult. Automatically deleting branches after pull request completion reduces repository maintenance overhead, improves visibility of active development branches, and helps enforce a consistent branch lifecycle management process.

Impact

  • Remove merged feature branches automatically after successful pull request completion.

  • Reduce unnecessary branch accumulation within the repository.

  • Improve repository organization and branch visibility.

  • Reduce manual cleanup activities for repository maintainers.

  • Help enforce standardized branch management practices.

Default Value

Depends on repository configuration. Bitbucket repositories do not always have automatic branch deletion enabled by default. Repository administrators must configure the branching model settings to automatically delete branches after pull requests are merged.

Pre-Requisites

  • Repository administrator access

  • An existing Bitbucket repository

Test Plan

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

  2. Navigate to the target repository.

  3. Select Repository settings.

  4. Navigate to Branching model settings.

  5. Review the pull request merge configuration.

  6. Verify that the option to automatically delete branches after pull request merge is enabled.

  7. If automatic branch deletion is disabled, follow the implementation steps.

Implementation Steps

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

  2. Navigate to the target repository.

  3. Select Repository settings.

  4. Navigate to Branching model.

  1. Locate the option for branch deletion after pull request merge.

  2. Enable:Delete the source branch after pull request is merged

  1. Save the changes.

  2. Verify that newly merged pull requests automatically remove the source branch after successful merge completion.

Backout Plan

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

  2. Navigate to the target repository.

  3. Select Repository settings.

  4. Navigate to Branching model settings.

  5. Locate the branch deletion after merge configuration.

  6. Disable:Delete the source branch after pull request is merged

  1. Save the changes.

  2. Confirm that repository operations function as expected after the rollback.

Reference