set default reviewers for pull requests globally

Copper Contributor

Is there a way that I can set 3 reviewers for all protected branches (we have 5) globally without having to go into all of our 40+ repositories and doing it for 4 branches each?    I tried to do this with manage repositories and then all repositories but the reviewers I added dont show in the individual repos when I drill down.  I need this so my merge automation works and approvers are already set as reviewers.


1 Reply

$mergeReposFile = Join-Path $PWD.Path ".\mergeReposInfo.json"
$mergeRepos = Get-Content -Raw -Path $mergeReposFile | ConvertFrom-Json
$DevOpsOrganization = ""
$DevOpsProject = "Company"
$Reviewers = "email address removed for privacy reasons"

foreach ($repoitem in $mergeRepos.repositories) {

$repositoryName = $
Write-Output "Repository: $repositoryName "
$repositoryID= $

$AppliedPolicy = az repos policy required-reviewer create `
--blocking $false `
--branch $repoitem.mastername `
--enabled $true `
--message "Automatically added as reviewer for by policy for $($ repo." `
--repository-id "$($repositoryID)" `
--branch-match-type "exact" `
--org $DevOpsOrganization `
--project $DevOpsProject `
--required-reviewer-ids $($Reviewers -join ";") | ConvertFrom-Json