Ivelius
Ivelius

Reputation: 5013

Gitlab CODEOWNERS to automatically add approvers

I love GitLab, but I am frustrated to assign approvers manually for each Merge Request. Gitlab friendly suggest to Tip: add a CODEOWNERS to automatically add approvers based on file paths and file types. And so I did , I have created a file under : .gitlab/docs/CODEOWNERS.txt Here is the contents of my file :

Multiple codeowners can be specified, separated by whitespace

CODEOWNERS @eduardo.baiao @n.belokopytov @viacheslav.iankovyi @yan.braslavsky

But unfortunately it does not auto assigns reviewers during Merge Requests. Did I do something wrong ? Am I missing something ?

Upvotes: 4

Views: 11043

Answers (2)

Grégoire Roussel
Grégoire Roussel

Reputation: 947

Looks like there is a confusion in the previous answers here between

  • approvers: the people that can click on 'Approve' to get the MR in a merge-able state. Potentially this list can be very long in a big company.
  • reviewers: a (usually) much shorter list of people you're asking to review this MR.

As a further clarification, I guess that the OP would like to choose the reviewers in the pool of approvers.

The OP is asking if Gitlab provides a feature to auto-choose reviewers, given the approval rules that apply to the current MR. Sadly, AFAIK, the answer is no.

However, you might want to look at what Gitlab itself is doing internally: their job danger-review leverages a library danger (https://danger.systems/js/) to run their "Reviewer Roulette": a process that assigns reviewer to a given MR (but I don't know if they take approval rules into account when doing so)

Upvotes: 4

Jonathan.Taylor
Jonathan.Taylor

Reputation: 362

Assigning approvers based on a CODEOWNERS file requires either GitLab Premium or GitLab Silver (or higher).

  • According to the Code Owners documentation, the CODEOWNERS file should be placed in either .gitlab/ or docs/ or the root directory. I don't think it will find it in .gitlab/docs.
  • Additionally, the docs specify that the file should be named CODEOWNERS, not CODEOWNERS.txt. Try removing the .txt extension and see if it works.
  • Make sure that you have "Require approval from code owners" enabled in Settings -> General -> Merge Request Approvals. Merge Request Approvals

Upvotes: 6

Related Questions