Bitbucket merge checks: which one stops the merge
Merge checks are the conditions a branch sets before its pull requests merge: enough approvals, passing builds, no open tasks. Whether an unmet check only warns or actually stops the merge depends on where the repository lives: in Bitbucket Cloud it stops the merge only with Premium and one more setting, in Bitbucket Data Center an enabled check vetoes the merge. When a pull request will not merge, the first question is which check is unmet, and the answer is often a detail of how that check counts.
Bitbucket Cloud
From Atlassian's page Suggest or require checks before a merge:
- The checks: Minimum number of approvals; Minimum number of approvals from default reviewers; No changes are requested; No unresolved pull request tasks; Minimum number of successful builds for the last commit with no failed builds and no in progress builds; Maximum number of commits behind destination branch.
- Warn or block: without Premium, Bitbucket warns about unresolved merge checks and the pull request can still be merged. To stop the merge, the workspace needs Premium and the branch the setting Prevent a merge with unresolved merge checks.
- Where: the repository's Settings → Branch restrictions (under Workflow); merge checks are part of a branch restriction for the target branch.
- Approvals: the author may approve their own pull request, but that approval does not count toward the minimum. With Premium, Reset approvals when the source branch is modified removes all approvals after a push, and Keep approvals if there is no change to the diff in the pull request keeps them when the diff stays the same.
Bitbucket Data Center
From Atlassian's page Checks for merging pull requests (Data Center 10.5):
- The built-in checks: All reviewers approve; Minimum approvals; Minimum successful builds; No 'changes requested' status; No incomplete tasks. Besides these, Code Insights checks (a report, its result, annotations of a severity) and Required builds (named builds on protected branches).
- Where: for all of a project's repositories, Project settings → Merge checks (a project admin can stop repositories from changing them); for one repository, Repository settings → Merge checks; Code Insights and Required builds have their own settings pages.
- Blocking: an enabled check vetoes the merge. The REST API answers
GET …/pull-requests/{id}/merge("Test if pull request can be merged") withconflicted, anoutcomeand a list ofvetoes, each with asummaryMessageand adetailedMessage: the checks' own words for what is missing.
What to look at
- Approvals: count the approvals of reviewers other than the author. In Bitbucket Cloud with Premium and approvals reset on push, a push after the approvals has removed them.
- Builds: in Bitbucket Cloud the check looks at every build status on the last commit of the source branch, and one failed status fails it, even if a later run of the same build passed. Atlassian's article Merge check fails when commit build statuses are created via Bitbucket Cloud API says to give the runs the same
key, so the newest status replaces the older one. - Tasks and requested changes: an open task, or a reviewer's "changes requested", keeps the check unmet until it is resolved or withdrawn.
- Commits behind: merge the target branch into the source branch, or rebase, and push.
- Conflicts are not a merge check but stop the merge as well: resolve them in a clone of the repository (merge or rebase locally) and push (resolving merge conflicts).
Merge checks in IntelliJ IDEA
Pull Request Inbox for Bitbucket, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, lists the pull requests that wait for your review in an IDE tool window, from Bitbucket Cloud and, in beta, from Bitbucket Data Center 8.9 or later. Next to each pull request it shows the merge checks in words: "1 of 2 approvals", successful builds, open tasks, commits behind the target branch, custom checks by name, conflicts, and which of them block the merge; from Data Center, the vetoes in the server's own words. The review inbox, diffs, discussions and merge checks are free; approving, commenting and merging are Pro (US$1.50 a month, with a 30-day trial).
Get it on JetBrains Marketplace
Bitbucket and Atlassian are trademarks of Atlassian; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by Atlassian or JetBrains.
More: pull request builds and Required builds · pull request tasks and default tasks · resolving comments · Request changes and Needs work · Bitbucket auto-merge · Bitbucket merge strategies · modify a pull request based on out-of-date information (Data Center) · pre-receive hook declined · Bitbucket merge queues · Bitbucket pull request plugins for IntelliJ IDEA, compared · 日本語