How to: Build Definitions and Tasks Mapping 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 Build Tasks;
  • $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 = "$($Organization)/"$uriProject = $UriOrganization + "_apis/projects?`$top=500"$ProjectsResult = Invoke-RestMethod -Uri $uriProject -Method get -Headers $AzureDevOpsAuthenicationHeaderForeach ($project in $ProjectsResult.value)
Write-Host $
$uriBuildDefinitions = $UriOrganization + "$($"    $BuildDefintionsResult = Invoke-RestMethod -Uri $uriBuildDefinitions -Method get -Headers $AzureDevOpsAuthenicationHeader    Foreach ($builDef in $BuildDefintionsResult.value)
Write-Host $
$uriBuildDef = $UriOrganization + "$($$($"        $BuildDefResult = Invoke-RestMethod -Uri $uriBuildDef -Method get -Headers $AzureDevOpsAuthenicationHeaderWrite-Host $BuildDefResult.process.phases
$uriTaskName = $UriOrganization + "_apis/distributedtask/tasks/$($"                $TaskNameResult = Invoke-RestMethod -Uri $uriTaskName -Method get -Headers $AzureDevOpsAuthenicationHeaderWrite-Host $TaskNameResult.value[0].name
  • Task Name (1) = Filter report using Task Name field;
  • Team Project Name (2) = Filter report using Team Project Name field;
  • Build Definition Name (3) = filter report using Build Definition Name field;
  • Build Definitions and Tasks Mapping Information (4) = List all information about Build Tasks, Project Name, Definition Name, and Number of usages from a respective task;
  • Number of usages = Looking at the example above, the DotNetCoreCli task is being used 4 times in the Build Definition ANP.Admin CI.




Tech Solution Architect Manager na Accenture

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

Recommended from Medium

Solution 11

Simple C++ Solution To Leetcode 725. Split Linked List In Parts

Creating a Simple Django API

N-ary Tree [DSA-2022]

Qubic status update February 3rd 2019

Website Video Production in Syderstone | ShowReel #Website #Video #Production #Syderstone https://t.

Community Annoucment 27/05/2021

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

Use a self-hosted agent for the Azure pipeline

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

Using user-assigned managed identities in Azure Automation Runbooks

💪Deploy F5 advanced WAF for Azure(PAYG) using Bicep Language