Enforcing pull request approvals from different groups in Azure DevOps

Tomomi Sako
2 min readOct 27, 2020
Photo by Jud Mackrill on Unsplash

In my current role, I spend most of my time developing code alongside our clients. We often have the situation where we want to ensure our PRs have at least one reviewer from our side and at least one from the client.

We do this to ensure collaboration with the client engineers. It helps to adjust the speed of the project since the code moves to the master branch in line with the skills and capacity of clients. If they need to upskill or know a particular technology before reviewing the PR we can identify the gap quickly and organize brown bag sessions or other training.

In this article, I will explain how to easily enforce this rule in Azure DevOps.

Set up the groups

  1. In Azure DevOps, go to Project Settings > General/Teams
  2. Create the groups: In the following example, I created Team Quokka and Team Redback
  3. Add your team members to each group
The official document about setting up the groups is here

Make the PR rule

  1. In Azure DevOps, go to Project Settings > Repos/Repositories
  2. Select repo and branch which you would like to set up the rule: In the following example, Default Project > policies > Branch Policies/master
  3. Select + icon button in Automatically included reviewers
  4. Put the groups which you created at the previous step in Reviewers and choose Required in Policy requirement
The official document about adding a new reviewer policy is here

Send a PR

Once you are done with the setup, now you are ready to send a PR. Because you set up the policy in which all PRs automatically include those two team members, you don’t need to add them by yourself.

In the screenshot, Jacob is in Team Redback and because he approved the PR, the check for Team Redback is also marked automatically. After a member of Team Quokka also approves then PR can be merged.

--

--