leusrox
leusrox

Reputation: 2385

Set default reviewers for merge request in GitLab

How I can set default reviewers in GitLab Premium?

In Settings → General I have only Merge request (MR) approvals, not reviewers.

Upvotes: 25

Views: 20948

Answers (5)

VonC
VonC

Reputation: 1327584

GitLab 17.6 (November 2024) comes with:

Enhanced merge request reviewer assignments

After you’ve carefully crafted your changes and prepared a merge request, the next step is to identify reviewers who can help move it forward. Identifying the right reviewers for your merge request involves understanding who the right approvers are, and who might be a subject matter expert (CODEOWNER) for the changes you’re proposing.

Now, when assigning reviewers, the sidebar creates a connection between the approval requirements for your merge request and reviewers. View each approval rule, then select from approvers who can satisfy that approval rule and move the merge request forward for you. If you use optional CODEOWNER sections those rules are also shown in the sidebar to help you identify appropriate subject matter experts for your changes.

Enhanced reviewer assignments is the next evolution of applying intelligence to assigned reviewers in GitLab. This iteration builds on what we’ve learned from suggested reviewers, and how to effectively identify the best reviewers for moving a merge request forward. In upcoming iterations of reviewer assignments, we’ll continue to enhance the intelligence used to recommend and rank possible reviewers.

https://about.gitlab.com/images/17_6/create-enhanced-reviewer-assignment.png -- Enhanced merge request reviewer assignments

See Documentation and Epic.

Upvotes: 0

Seega
Seega

Reputation: 3400

You can use "Default description template for merge requests" either via Settings->Merge Requests or via file in .gitlab/merge_request_templates to do it via a workaround. (Doc)

In the template you can use the chat code

/assign_reviewer @user1 @user2 @user3

to automatically assign user1, user2 and user3 as reviewers when creating a new MR.

Upvotes: 37

Arty-chan
Arty-chan

Reputation: 3008

There is no such setting in the UI. If you think it would be useful to others, please file a feature request.

As a workaround, you could use the Merge requests API to set reviewers when creating the MR or by updating it after creation.

How you want to achieve the desired result depends on your workflow.

For example, you could have something subscribe to the project webhook which triggers a script that does the API call whenever it sees an open MR event.

Another option, if you run pipelines on MRs, you can have a job run a script which could set reviewers if none are already set via the API.

Yet another option would be to have a specified reviewer set when a merge request is created through the /assign_reviewer @user quick action by adding it to the default and all MR template files.

Upvotes: 10

Tjad Clark
Tjad Clark

Reputation: 1078

Might be a useful workaround as this does not add you as a reviewer. (especially for gitlab free/CE 14.8+, as multiple reviewers are only available for Premium)

You could add a Reviewers section to your default MR template. Then persons will be notified with a Todo for the MR upon creation.

This should be in your default branch.

.gitlab/merge_request_templates/default.md


## What this MR does / why we need it 
- description
- proof of work


## Reviewers

- [ ] Reviewed by @gitlabUser1
- [ ] Reviewed by @gitlabUser2
- [ ] Reviewed by @gitlabUser3
- [ ] Reviewed by @gitlabUser4
- [ ] Reviewed by @gitlabUser5

Thanks for your MR, you're awesome! :+1:

The user can then check the checkbox upon review which will change the MR history too.

Upvotes: 5

Sandeepp
Sandeepp

Reputation: 32

Could you please try below

In Settings-->General-Merge Request Approvals. enter image description here

Click on Add approval Rule.

enter image description here

Add Rule name as "Default", Approvals required, desired branch and add members under approvers.

These approvers would be your default reviewers for any Merge request.

Upvotes: -5

Related Questions