CODEOWNERS not working for workspace user groups
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
When using the CODEOWNERS feature, the workspace user groups defined as the owners of a path/pattern are not automatically assigned as reviewers in pull request creation.
Diagnosis
CODEOWNERS
file exists in the.bitbucket
directory in the destination branch of the pull requestCODEOWNERS
file has one or more rules to define a workspace user group as the owner of a path/pattern. E.g :1 2 3 4 5
# Choose all members of a workspace group *.js @workspace-slug/MyTestGroup # Choose group members tagged on the fewest open PRs *.py @workspace-slug/Developers:least_busy(2)
When a pull request is created, no members of the defined user group are assigned as reviewers
Cause
Since the groups are saved as a group slug on the database, using the group name when referencing a group in the CODEOWNERS file makes Bitbucket Cloud unable to match the group defined in the code owners rule with an existing group slug in the workspace.
A group slug is a URL-friendly version of a group name, automatically generated by Bitbucket for use in the URL. For example, if your group name is "Test Group", in the URL it would become "test-group".
Solution
All the user group references in the CODEOWNERS file should be using the group slug.
For example :
For a user group named MyTestGroup, the codeowners rule should reference mytestgroup:
1 2
# Choose all members of a workspace group *.js @workspace-slug/mytestgroup
For a user group named Developers, the codeowners rule should reference developers:
1 2
# Choose group members tagged on the fewest open PRs *.py @workspace-slug/developers:least_busy(2)
For a user group named Group#1, the codeowners rule should reference group-1:
1 2
# Choose group members tagged on the fewest open PRs *.py @workspace-slug/group-1:least_busy(2)
If you are in doubt what is the slug of a group, you can find it by following the below steps :
Navigate to Workspace Settings > User Groups
Open the user group you want to know the slug
Look for the part of the URL that contains the group slug:
1
https://bitbucket.org/<workspace>/workspace/settings/groups/<group-slug>
For more details and examples on the CODEOWNERS syntax, please reference Setup and use code owners.
Was this helpful?