How to: Create Dashboard to visualize Branches ahead/behind

  1. PowerShell script will receive the following parameters:
  • $PAT = Personal Access token to connect on Azure DevOps;
  • $Organization = Organization URL to list Repositories and Branches on each project;
  • $Connstr = connection string to Azure SQL Database that stores the report information. To create this report, it’s necessary to create previously a Azure SQL Server and Database and run a script below:
$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($PAT)")) }$UriOrganization = "https://dev.azure.com/$($Organization)/" $uriProject = $UriOrganization + "_apis/projects?`$top=500"$ProjectsResult = Invoke-RestMethod -Uri $uriProject -Method get -Headers $AzureDevOpsAuthenicationHeaderForeach ($project in $ProjectsResult.value)
{
Write-Host $project.name
}
$uriRepositories = $UriOrganization + "$($project.id)/_apis/git/repositories?api-version=6.1-preview.1"    $RepositoriesResult = Invoke-RestMethod -Uri $uriRepositories -Method get -Headers $AzureDevOpsAuthenicationHeader    Foreach ($repo in $RepositoriesResult.value)    
{
Write-Host $repo.name
}
$uriRepositoryStats = $UriOrganization + "$($project.id)/_apis/git/repositories/$($repo.id)/stats/branches?api-version=6.1-preview.1"            $RepositoryStatsResult = Invoke-RestMethod -Uri $uriRepositoryStats -Method get -Headers $AzureDevOpsAuthenicationHeader            Foreach ($repostats in $RepositoryStatsResult.value)            
{
Write-Host $repostats.name
}
  • Project Name (1) = Filter report using Project Name field;
  • Repository Name (2) = Filter report using Repository Name field;
  • Branch Name (3) = Filter using Branch Name field;
  • Branches Information (4) = List all information about Branches and Stats (Team Project, Repository, Branch, Behind Count, Ahead Count).

--

--

--

Tech Solution Architect Manager na Accenture

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

Recommended from Medium

Developing a Flutter Native Plugin —A Real-world Scenario

Date — The Command

CosmWasm: Request For Comments

CS 373: Blog #11

CLOUD COMPUTING

Python: Send Line Message with Sticker and Image (Python串接Line)

Writing Junit Test Cases and Its Practices

ANDROID LIBRARIES 📚

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

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

💪Azure Bicep Language - Build a WordPress environment using Bicep modules

Getting setup quickly with Dependency-Track using Azure Container Instances

Use a self-hosted agent for the Azure pipeline