CODEOWNERS doesn't work
Asked by Reinaldo Andr?s Arias Pinto:

I was following this tutorial <https://support.atlassian.com/bitbucket-cloud/docs/set-up-and-use-code-owners/>  
but doesn't work, any idea about this?


Answers:
author: Patrik S
body: Hello all,

If you are referencing a workspace user group in your codeowners file, make sure that the group-slug is provided in the rule as follows :

```
<file pattern> @workspace-slug/group-slug
```

For example, for a user group named **MyTestGroup,** the codeowners rule should reference **mytestgroup** :

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

If you use the group name instead of the slug, bitbucket will not be able to match the rule with the actual group.

This is explained more in detail in the following article, along with instructions on how to find the group slug :

* [Codeowners not working for workspace user groups](https://confluence.atlassian.com/bbkb/codeowners-not-working-for-workspace-user-groups-1387866531.html?_cachebust=9793444765)

Thank you!

Patrik S

comments: author: Stephen Baker
body: Thanks for your answer [@Patrik S](/t5/user/viewprofilepage/user-id/4603309) . I read through the article carefully and have re-read [the docs](https://support.atlassian.com/bitbucket-cloud/docs/set-up-and-use-code-owners/) countless times, but it just won't work. Is the **workspace-slug** just the slug itself (workspace-name), or does it need to be a full URL (<https://bitbucket.org/workspace-name>)? I have been using just the slug, but it doesn't like it. The docs barely even mention the workspace-slug stuff, so I'd really appreciate some guidance on this, and I'm sure others would as well.


author: Patrik S
body: Hello [@Stephen Baker](/t5/user/viewprofilepage/user-id/5031160) ,

The formatting to reference a workspace user group contains an @ symbol followed by the *workspace-slug*:

```
*.py @workspace-slug/group-slug
```

You can find the workspace-slug by navigating to your workspace and checking the URL, which will be in the format :

```
https://bitbucket.org/<workspace-slug>/<rest of the URL>
```

Some things I would suggest double-checking that may be causing the code owners not to work :

* CODEOWNERS file needs to be present in the ++destination branch++ of the pull request
* The file should be named CODEOWNERS in uppercase letters.
* The CODEOWNERS file needs to be placed inside a folder named **.bitbucket** , and this folder must be in the root directory of the repository (the absolute path to the file should be *.bitbucket/CODEOWNERS*)

If this still doesn't work, would you mind sharing your CODEOWNERS file here? In case you prefer not to share here as it's a public forum, please let me know, and I can raise an internal support ticket to investigate this further.

Thank you, [@Stephen Baker](/t5/user/viewprofilepage/user-id/5031160) !

Patrik S


author: Stephen Baker
body: I basically posted it already in my message on April 29th. But here is the exact one-liner in my *.bitbucket* /CODEOWNERS file:  

\* @tcg-machines/javascripters:all


author: Patrik S
body: Thanks for confirming [@Stephen Baker](/t5/user/viewprofilepage/user-id/5031160) !

I tested using the same rule as you posted, just changing the workspace slug to reflect my own workspace, and the reviewers were successfully assigned when creating a new pull request.

In this case, as we already went through different tests that could be causing the reviewers not to be added, I will be raising a support ticket for you to investigate this further.

You should be receiving an email with the ticket link in a few minutes, but in case you don't, please let me know so I can share it with you here (only you and Atlassian will have access to the ticket).

Thank you, [@Stephen Baker](/t5/user/viewprofilepage/user-id/5031160)


author: Reinaldo Andr?s Arias Pinto
body: For me it doesn't work with any of these configurations.

```
* @username
```

```
* username
```

```
* @email
```

```
* email
```

```
* @workspace/username
```

```
* @workspace/email
```

Also I tested using a teams.yaml an nothing


author: Patrik S
body: Hey [@Reinaldo Andr?s Arias Pinto](/t5/user/viewprofilepage/user-id/5486678) ,

The syntax is different depending on which type of user you are referencing :

* Reference a user by the email :

  ```
  * user1@example.com user2@example.com
  ```

* Reference the user by the username

  ```
  * @username1 
  ```

* Reference a workspace user group

  ```
  * @workspace-slug/group-slug
  ```

* Reference a group defined in the team.yaml file :

  ```
  * @teams/frontend
  ```

Could you try using the syntax as above and also grant that the .bitbucket/CODEOWNERS file is present in the destination branch of the pull request?

Also, I see you have access to a workspace with an active subscription that is entitled to our Premium support, so if you are still facing issues with the syntax above, let me know so I can open a support ticket for you.

Thank you, [@Reinaldo Andr?s Arias Pinto](/t5/user/viewprofilepage/user-id/5486678) !

Patrik S


author: Reinaldo Andr?s Arias Pinto
body: that is what I said before, I've tried with all of those syntax and didn't work also using team.yaml .  
what I did:

branch **A** with .bitbucket/CODEOWNERS and with all of these syntax.  
\* user@email.com  
\* [@User](/t5/user/viewprofilepage/user-id/115298)@email.com  
\* [@username](/t5/user/viewprofilepage/user-id/1677494)  
\* username  
\* @workspace/username  
\* @workspace/user@email.com  
PR from branch **B** pointing to branch **A**, and nothing happen


author: Patrik S
body: Hey [@Reinaldo Andr?s Arias Pinto](/t5/user/viewprofilepage/user-id/5486678) ,

Thank you for your time in testing those possible scenarios.

I went ahead and created a support ticket for you using the email of your community account. You should be receiving an email with the ticket link soon. Let me know if you don't receive it so I can share it with you here.


author: Reinaldo Andr?s Arias Pinto
body: I have not received


author: Patrik S
body: Hey [@Reinaldo Andr?s Arias Pinto](/t5/user/viewprofilepage/user-id/5486678) ,

You can access the ticket directly in the support portal, while logged in, through the following link :

* [BBS-217558](https://support.atlassian.com/requests/BBS-217558/)


author: Stephen Baker
body: Same issue here. I received an email with a link to [this](https://bitbucket.org/blog/code-owners?utm_source=newsletter-email&utm_medium=email&utm_campaign=april2024-BB-digest_EML-18132&jobid=106493033&subid=1613409111) and quickly added a .bitbucket/CODEOWNERS file to my project but when I created a pull request, the Reviewers were never populated. I made several pull requests after checking in the required CODEOWNERS file, and no dice. Hopefully someone can help us fix this.  

My file only has one line in it. For the sake of this example, let's say my workspace slug is **spider-man** . I also have a group called **javascripters** with 3 members associated to it. This is my file:  

\* @ spider-man/javascripters:all  

In the snippet above, since the formatting in this text editor does too much magic, I had to add a space after the **@** symbol that I don't actually have in my real file.  


Tags: bitbucket-cloud

cloud