How to: Viewing which repositories have branch policies on Azure DevOps

  1. PowerShell script will receive the following parameters:
  • $PAT = Personal Access token to connect on Azure DevOps;
  • $Organization = Organization URL to list all branches and policies.
$ProjectsResult = az devops project list --org $Organization | ConvertFrom-Json 
Foreach ($project in $ProjectsResult.value)
{
Write-Host $project.id
}
$ReposResult = az repos list --org $Organization --project $project.id | ConvertFrom-Json
Foreach ($repo in $ReposResult)
{
Write-Host $repo.id
}
$ReposPolicyResult = az repos policy list --branch $repo.defaultBranch --org $Organization --project $project.id --repository-id $repo.id | ConvertFrom-Json
Foreach ($repoPolicy in $ReposPolicyResult)
{
Write-Host $repoPolicy.type.displayName
}
{
"RepositoryId": "[Repository ID]",
"RepositoryDefaultBranchRequiredReviewers": true,
"RepositoryDefaultBranchCommentRequirements": true,
"TeamProjectName": "[Team Project Name]",
"TeamProjectId": "[Team Project Id]",
"RepositoryDefaultBranchWorkItemLinking": true,
"RepositoryURL": "[Repo URL]",
"RepositoryDefaultBranch": "refs/heads/master",
"RepositoryName": "WorkItemDeployment",
"RepositoryDefaultBranchBuild": true,
"RepositoryDefaultBranchMinimumNumberOfReviewers": true
}
  • Require a minimum number of reviewers
  • Automatically include code reviewers
  • Check for comment resolution
  • Build validation
  • Check for linked work items

--

--

--

Tech Solution Architect Manager na Accenture

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How much does it cost to develop an app?

Paas Deployment: Why Your Business Should Switch To PaaS in 2022

Developing My First Website | Just The Beginning

AWS CodeCommit on OSX & unable to access / returned error: 403

撸价值空投

📣MetaWorld Breaking News📣

Release Notes: Editors & Admins

What is the difference between a hard link and a symbolic link?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vinicius Moura

Vinicius Moura

Tech Solution Architect Manager na Accenture

More from Medium

Azure Sphere

Getting list of Azure subscriptions of customers who deployed your Azure Managed Application

How to: Team Projects, Fields, and Picklists Mapping on Azure DevOps

Azure Front Door