Bitbucket default reviewers: setting them, requiring them, and the REST API
Default reviewers are the people Bitbucket puts on a new pull request for you. Bitbucket's own create page fills them in; a pull request created through the REST API may have none. On Data Center the create call does not add them: Atlassian answered that they are "only treated as a suggestion" to the person creating the pull request (BSERV-9860). Cloud's documentation does not say its create call adds them. A tool that creates pull requests should read them and send them.
Bitbucket Cloud
- Project and repository. Default reviewers set in a project's settings (Pull Requests > Default reviewers) are added to pull requests in every repository of the project, unless the repository's settings say otherwise; a repository can have its own as well. They must be members of the workspace, with at least Read permission on the project (Atlassian's documentation).
- Requiring their approval. The merge check Minimum number of approvals from default reviewers counts only their approvals. It stops a merge only on the Premium plan with Prevent a merge with unresolved merge checks; otherwise Bitbucket warns and still lets you merge (merge checks; more in Bitbucket merge checks).
- Through the REST API.
GET /2.0/repositories/{workspace}/{repo_slug}/effective-default-reviewersreturns the repository's default reviewers together with those it takes from its project (default-reviewersalone returns only the repository's). Send them in the create call as"reviewers": [{"uuid": "{…}"}], leaving out the author. - Someone who left the workspace. A user removed from the workspace stayed in the default reviewers list, and creating a pull request then failed with "… is not a member of this workspace and cannot be added to this pull request" until that user was removed from the list (BCLOUD-23332, closed as fixed).
- Code owners are a separate thing. Reviewers from a CODEOWNERS file are added only when the pull request is created on the website, not through the REST API (BCLOUD-23663, open).
Bitbucket Data Center
- Rules. A project admin sets rules in Project settings > Default reviewers, a repository admin in Repository settings > Default reviewers. Each rule names a source branch and a target branch (a branch name, a branch pattern, a type from the branching model, or any branch), the default reviewers (users, or reviewer groups whose members are added), and optionally Approvals required: how many of them must approve before the pull request can be merged (Atlassian's documentation).
- On the create page. When the target branch has default reviewers, they are filled in on a new pull request or draft. The person creating it can remove some; a Default reviewers button then adds back the rest.
- Through the REST API. The create call (
POST …/pull-requests) does not add them. Read them first withGET /rest/default-reviewers/1.0/projects/{projectKey}/repos/{repositorySlug}/reviewers?sourceRepoId=…&targetRepoId=…&sourceRefId=…&targetRefId=…, which returns the users the matching rules name. From 8.0 the refs are branch names or tags, not commit hashes (Atlassian's knowledge base). Then send them as"reviewers": [{"user": {"name": "…"}}].
Default reviewers in IntelliJ IDEA
Pull Request Inbox for Bitbucket, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, lists the pull requests of Bitbucket Cloud and, in beta, of Bitbucket Data Center 8.9 or later in an IDE tool window, with each one's reviewers and merge checks. From version 1.0.37, a pull request it creates from the current branch gets the repository's default reviewers, read as above, without you; if Bitbucket refuses one of them, the pull request is created without them and the notification says why. From version 1.0.46, Add reviewers asks more people on a pull request already open, picked from the repository's recent pull requests, and keeps those already on it. The review inbox, diffs, discussions and merge checks are free; creating, approving, commenting, adding reviewers 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: find every pull request waiting for your review · Bitbucket merge checks · default tasks · Bitbucket draft pull requests · Bitbucket pull request plugins for IntelliJ IDEA, compared · 日本語