CODEOWNERS on project level?
Asked by Hannes Kirsman:

Hi!

I wanted to ask if it would be somehow add people to codewners group on project level even if the person does not have access to all of the repos under that project? It seems it's not currently possible.

I'm actually working in a company that has it's own <https://bitbucket.company.tools/> Bitbucket. There's project that has lot of repos, but then I and some other devs have access to only about 10. It would be nice if there was one place to create some groups, then add them via the CODEOWNERS file. Now it seems we need to manage them repoy by repo.


Answers:
author: Michael R?egg _Mibex Software_
body: As my colleague Roman mentioned, we have been working on a tool that allows you to share common configurations like Code Owners across repositories.

<br />

This tool is now available and it is called [DevSensei Pull Request Workflow Automation](https://marketplace.atlassian.com/apps/1218598/devsensei-pr-workflow-automation-code-owners-for-bitbucket?hosting=datacenter&tab=overview). Its configuration is YAML-based in a file called devsensei.yaml, so you have all the advantages of configuration as code.

<br />

By using Bitbucket reviewer groups, you can configure your reviewers on a project level (see example below: frontendTeam).

<br />

And you can even share your Code Owner rules across repositories of your project by including workflows from another repository.

<br />

Here's an example:

**commons/devsensei.yaml**

```
workflows:
  - name: Add Code Owners
    conditions:
      - destination=develop
    actions:
      - add-codeowners:
        rules: |
          *.js @@frontendTeam
```

**repo_a/devsensei.yaml**

```
includes:
  - commons/devsensei.yaml
```

**repo_b/devsensei.yaml**

```
includes:
  - commons/devsensei.yaml
```

Does that help you? You can find more information in the [docs](https://docs.mibexsoftware.com/codeowners/devsensei-pr-workflow-automation).

<br />

Best,  
Michael from Mibex (app vendor of[DevSensei Pull Request Workflow Automation](https://marketplace.atlassian.com/apps/1218598/devsensei-pr-workflow-automation-code-owners-for-bitbucket?hosting=datacenter&tab=overview))

comments: author: Hannes Kirsman
body: It might help in some cases where config needs to unified, tx!

I think it would not help in case you have set user to multiple repos to a group and then you have to remove them at some point so you'd have to do it multiple times.


author: Hannes Kirsman
body: Thanks for the reply!

I'm ok with copying the file around and it's content very per repo. Some repos are for front-enders, some for backenders, some for infra etc. I'd assume we would have groups like @@GroupFrontend,@@GroupBackend etc. We'd like one place to manage these groups not manage them in 10 repos. Adding same groups 10 times, removing person from it 10 times if somebody leaves. The CODEOWNSERS file probably would not change at all (ideally). I doubt some theme repo would suddenly needs backendenders group.

So we initially saw that we could do it from project level where all repos are. Then the admin who tried to add said they could not add us (probably because we don't have access to many other repos). That's the guess anyways.

comments: author: Roman Stoffel
body: Ok: So copying the CODEOWNERS file is fine at the moment.  

So, in Codeowners for Bitbucket (the app, not the built in functionality), the groups can are also resolved again Bitbucket Reviewer Groups (DC), which can be defined on project or repo level.

So, in Bitbucket DC you then can have CODEOWNER files at repository level reference these reviewer groups. And update the reviewer groups at project level with new members / remove members.

On Bitbucket Cloud there is afaik no such concepts yet. There are Groups on the Workspace level, and those are used.

That are the solutions approaches that I am aware of.  

PS: As mentioned we are working on more 'Project oriented' CodeOwner features for the app =). But that is in its design phase =).


author: Roman Stoffel
body: Hi.

Disclaimer: I'm working in the team for the Codeowners for Bitbucket app, which extends the built in code owner features.

Is it for Bitbucket DC or Bitbucket Cloud?

<br />

What exactly do you want to share?  
1. Sharing the CODEOWNER file over a project?  
2. Or are you ok with the CODEOWNER file copied over, but you want to be per-project flexible on who to assign?  

For 1. In general, we are working at the moment on concepts to extend our Codeowners app to give more high level, project wide features. But that is in a very early stage.  

For 2. What you could do (at least with the Codeowners for Bitbucket app) is to only use groups in the Code owner files:  

\`\`\`  
\*\*/\*.java @@JavaExperts  
frontent/\* @@FrontendExperts  
\`\`\`  

And the use Bitbucket Reviewer Groups on a per project level who is in the @@JavaExperts \& @@FrontendExperts group. However, the CODEOWNER file still need copy and pasting over all projects.  


Tags: bitbucket-data-center

data-center