Forum Discussion
set default reviewers for pull requests globally
$mergeReposFile = Join-Path $PWD.Path ".\mergeReposInfo.json"
$mergeRepos = Get-Content -Raw -Path $mergeReposFile | ConvertFrom-Json
$DevOpsOrganization = "https://dev.azure.com/company"
$DevOpsProject = "Company"
$Reviewers = "email address removed for privacy reasons"
foreach ($repoitem in $mergeRepos.repositories) {
$repositoryName = $repoitem.name
Write-Output "Repository: $repositoryName "
$repositoryID= $repoitem.id
$AppliedPolicy = az repos policy required-reviewer create `
--blocking $false `
--branch $repoitem.mastername `
--enabled $true `
--message "Automatically added as reviewer for by policy for $($Repository.name) repo." `
--repository-id "$($repositoryID)" `
--branch-match-type "exact" `
--org $DevOpsOrganization `
--project $DevOpsProject `
--required-reviewer-ids $($Reviewers -join ";") | ConvertFrom-Json
}