Automatically assign code owners as pull request reviewers

As your team and products expand, expertise in various areas of your code base may become distributed among different team members, or across teams. This can create challenges when trying to identify the best qualified people to assign as pull request reviewers.

We have a new solution for this in Bitbucket Cloud: You can now designate suggested reviewers for specific areas of the code base by adding a code owners configuration file to your repository. This file is a set of rules describing which people own specific paths/patterns in your repository. Based on these rules, Bitbucket can then automatically assign reviewers to a pull request based on which files are being modified.

When you create a new pull request, Bitbucket automatically checks whether a CODEOWNERS file exists in the .bitbucket directory of the repository. If the file is found, every rule in that file is compared to the diff of your pull request. For each matching rule, the users associated with it are automatically added as suggested reviewers.

Learn more about code owners

Flexible and powerful

The code owners syntax gives you the flexibility to assign individuals, groups or custom-defined teams as default reviewers for specific file paths or patterns. When working with groups and teams, you can specify how many reviewers to select, and how they should be chosen. Here are a few usage examples:

# .bitbucket/CODEOWNERS

# Default reviewers for files not matching patterns below

# Choose all members of a workspace group
*.js   @workspace-slug/frontenders:all

# Choose group members tagged on the fewest open PRs
*.py   @workspace-slug/backenders:least_busy(2)

# Choose randomly from a custom team (defined in teams.yaml)
*.tf   @teams/sre-leads:random(2)

Ready to see code owners in action? Simply add a CODEOWNERS file to the .bitbucket directory in your repository, then open a new pull request.

To learn more about code owners syntax, check out the reference guide.

Get started with smarter code reviewer assignment

The code owners feature is available now for all teams using Bitbucket Cloud. We're excited about the potential of this feature to help your teams do better, smarter code reviews. As always, please feel free to share your thoughts with us through the help '?' menu > Give feedback.