How to: Create Dashboard to visualize Branches ahead/behind

This script and report extract all repositories and branches on each Team Project in Azure DevOps to identify the gap between each branch and the default branch

An original script is available on my GitHub repository. See below this script:

Let’s go understand each command used.

  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:

2. Projects List = use this REST API to list all projects on the Azure DevOps organization.

3. Repositories List = use this REST API to list all repositories on each Team Project

4. Stats List = use this REST API to list all branches on each repository

5. After extract all branches, and stats, this information is stored in a table in Azure SQL.

6. After insert information into a table, I connected this database on Power BI:

  • 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).

DevOps Consultant at N3