How to: List all Build Definitions and their latest executions 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 Team Projects, Build Definitions and latest executions;
  • $Connstr = connection string to Azure SQL Database that stores the report information. To create this report, it’s necessary to create previously an 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
}
$uriBuildDefinitions = $UriOrganization + "$($project.id)/_apis/build/definitions?api-version=6.1-preview.7"    $BuildDefintionsResult = Invoke-RestMethod -Uri $uriBuildDefinitions -Method get -Headers $AzureDevOpsAuthenicationHeader    Foreach ($builDef in $BuildDefintionsResult.value)
{
Write-Host $buildDef.name
}
$uriLatestBuild = $UriOrganization + "$($project.id)/_apis/build/latest/$($builDef.id)?api-version=6.1-preview.1"        $LatestBuildResult = Invoke-RestMethod -Uri $uriLatestBuild -Method get -Headers $AzureDevOpsAuthenicationHeaderWrite-Host $LatestBuildResult.buildNumber
  • Project Name (1) = Filter report using Project Name field;
  • Build Definition Name (2) = Filter report using Build Definition Name field;
  • Build Result (3) = filter report using Build Result field;
  • Build Reason (4) = filter report using Build Reason field;
  • Requested For (5) = filter report using Requested For field;
  • Branch (6) = filter report using Branch field;
  • Build Definitions and latest executions (7) = List all information about Team Projects, Build Definitions, Build Number, Build Reason, Build Result, Build Requested For, Branch Name, Commit Number, Build Start Time, Build Duration, and respective Link to redirect it to Azure DevOps;
  • Charts (8) = Charts to view aggregate information about this report.

--

--

--

Tech Solution Architect Manager na Accenture

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

Recommended from Medium

Algorithmic Trading with Williams %R in Python

Java Interview Questions For Beginners — 1 (OOP Concepts)

Closed Captioning Provided by … Watson!

Mongodb REPLICATION

Build a Fast Food Order Taker in Python

Secret Codes and Gift Cards are now LIVE!

Meta-pipelines — Part 4 — Deploy and Run

Linux basic commands to get you started

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

Configure RBAC for Cosmos DB with Managed Identity instead of Service Principal

How to: Release Badges Dashboard on Azure DevOps

Creating and Provisioning Azure Container Apps with Bicep

Assigning Azure built-in roles vs Azure AD built-in roles with Azure CLI