Get started with Bitbucket Cloud
New to Bitbucket Cloud? Check out our get started guides for new users.
Bitbucket Cloud offers built-in branch restrictions that allow your project and repository teams to set up prerequisites that must be met before merge commands are allowed for pull requests.
If you find that the branch restrictions we offer out of the box don’t suit your organisation’s unique workflows, Bitbucket Cloud also supports custom merge checks.
The benefit of using app-based custom merge checks is that you are in complete control of the these checks, allowing you to create consistent, safe, and quality focussed workflows regardless of your requirements.
On premium plans, you can also set and enforce these checks at workspace, project, or repository levels, allowing your organisation to enforce quality standards as broadly or specifically as needed.
Custom merge checks are an advanced feature. To use custom merge checks, you must first build and install a custom merge check Forge app.
Use our developer tutorial to learn how to create a custom merge check app.
Alternatively, if you’d like to install an app created by a third party vendor, keep reading to learn how to install a ready-made app.
Forge apps are not supported on personal workspaces. See set up a shared team workspace.
You must be a Workspace admin to configure and set up custom merge checks.
To configure custom merge checks:
Install a custom merge check app in your workspace via one of the following two options:
Install an app you or your team has created via the Forge CLI forge install command if you have the app source code. Refer to the our developer documentation for more details on creating custom merge check apps. If you are looking for specific details about the Install command, refer to Install command.
Install an app that someone else has created via a direct distribution link given to you by the app developer. Refer to the Distribute your apps developer doc for more details.
Select Settings in the upper-right corner of the top navigation bar and select Workspace settings.
Select Custom merge checks under Workflow on the left navigation bar.
Select Enable to enable the custom merge check feature for your workspace.
Once enabled, all custom merge checks available from the installed forge apps will be displayed in Custom merge checks page under Workflow in workspace, project and repository settings pages.
Checks enabled at the repository level will run against all pull requests contained within the repository, provided the pull request target branch matches a configured checks enabled branch.
You must be a repository admin to administer the custom checks at the repository level.
To administer custom merge checks associated with the repository:
Select Repository settings in the left sidebar of the repository.
Select Custom merge checks under Workflow on the left sidebar.
If you do not see a table, it means you do not have any Forge Apps installed which provide Custom Merge Checks. You will have to install an app into your workspace prior.
Click the Add check button on a Forge app shown in the table.
Select the name of the app's merge check you’d like to enable.
Select the target branch you’d like the custom check to be run against.
Click Save which will cause that check to come into effect for all pull requests.
Premium-only feature
If you have a Premium plan, you can tick required which will enforce the check must pass before a pull request can be merged
Checks enabled at the project level will run against all pull requests contained within all repositories contained within the project. Provided the pull request targets a branch which corresponds to the enabled custom checks.
You must be a project admin to administer the custom checks at the project level.
Premium-only feature
If you have a Premium plan, you are able to administer custom checks at the project level
To administer custom merge checks associated with the project:
Select Project settings in the left sidebar of the project.
Select Custom merge checks under Workflow on the left sidebar.
If you do not see a table, it means you do not have any Forge Apps installed which provide Custom Merge Checks. You will have to install an app into your workspace prior.
Click the Add check button on a Forge app shown in the table.
Select the name of the app's merge check you’d like to enable.
Select the target branch you’d like the custom check to be run against.
Select whether or not the check is required
Click Save which will cause that check to come into effect for all pull requests.
Checks enabled at the workspace level will run against all pull requests contained within all repositories contained within all projects contained within the workspace. Provided the pull request targets a branch which corresponds to the enabled custom checks.
You must be a workspace admin to administer the custom checks at the project level.
Premium-only feature
If you have a Premium plan, you are able to administer custom checks at the workspace level
To administer custom merge checks associated with the project:
Select Project settings in the left sidebar of the project.
Select Custom merge checks under Workflow on the left sidebar.
If you do not see a table, it means you do not have any Forge Apps installed which provide Custom Merge Checks. You will have to install an app into your workspace prior.
Click the Add check button on a Forge app shown in the table.
Select the name of the app's merge check you’d like to enable.
Select the target branch you’d like the custom check to be run against.
Select whether or not the check is required
Click Save which will cause that check to come into effect for all pull requests.
Once you’ve installed a custom merge check app and enabled the feature at the workspace level, you can set up custom merge checks at each level of the Bitbucket resource hierarchy: workspace, project, and repository.
This allows organisations (workspace level) to mandate a set of checks that must run across the entire workspace, and gives teams (projects) the ability to also mandate checks running within that project, and finally individual repositories may also set checks.
These checks are inherited. That is a check that is required at the workspace level can not be disabled at a lower level (project or repository).
The checks are also complementary. The same check can be (not that we advise it) at multiple levels, each producing an independent result in the pull request.
That enables a workspace to set a check as not required and a contained project (or repository) could enable the same check targeted against the same branch as required.
Workspace and project level settings, and required custom merge checks are only available on premium plans.
As an example, in the repository below:
Any pull request targeting the repository’s configured main branch will run the following merge checks.
Required number of builds passed
All tasks resolved (Inherited from the repository's project)
Minimum approvals (Inherited from the repository's workspace)
And will require a passing result for both the inherited checks (as they’ve been configured as required).
Custom merge checks run in the context of a pull request. Once you’ve enabled a merge check, you will see results for the enabled check results in the Pull Request page.
For pull requests created prior to the custom merge check was enabled, you may not immediately see a corresponding check result in the UI. However, when a merge is attempted, the merge attempt will be blocked as the corresponding result is missing. At this point, the missing check will be queued and executed. From this point forward, this pull request will remain in sync.
Any PR created from this point in time will automatically queue and execute any custom checks configured against the target branch.
Any check which is configured to be not required will be executed, but will not prevent a merge.
A custom check can be pre-merge, on-merge, or both. The type of the check depends on what trigger it is subscribing to in its Forge app manifest. The merge check type is displayed in the add/edit modal in the Custom merge checks setting table.
Pre-merge checks are triggered as different events occur on an open PR prior to it being merged. For example, when code has been pushed to the source branch of the pull request (on-code-pushed) or when an approval is changed (on-reviewer-status-changed). Any custom merge check which is pre-merge must produce a successful result (if required) prior to a merge action being invoked.
On-merge checks are integrated into the merge process itself, and are only triggered after the Merge button (or api) has been hit. Failed on-merge checks which are set as required will result in a pull request merge failure.
Was this helpful?