This feature update was also published on the Bitbucket blog.
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.
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 to get you started:
# .bitbucket/CODEOWNERS
# Default reviewers for files not matching patterns below
* alisha@example.com fred@example.com
# 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 all about code owners syntax, check out the reference guide.
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.
Dave Parrish _Atlassian_
Product Manager, Bitbucket
Atlassian
San Francisco
23 accepted answers
5 comments