How to: Build Definitions and Tasks Mapping on Azure DevOps

This script and report extract all Build Tasks on any Build Definitions to map where they are being used within the Azure DevOps organization

This report was based on the extension Build Task Explorer. Thanks, Mathias Olausson for inspiring this publication.

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 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:

2. Projects List = uses this REST API to list all Team Projects on Azure DevOps organization

3. Definitions List = uses this REST API to list all Build Definitions on each Team Project

4. Definitions Get = uses this REST API to get details about Build Definition

5. Build Task Details = uses this REST API to get details about Build Task

6. After extract all Team Projects, Build Definitions, and Build Tasks, this information is stored in a table in Azure SQL.

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

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

DevOps Consultant at N3