How to: Release Definitions and Tasks Mapping on Azure DevOps

Vinicius Moura
2 min readOct 20, 2021

This script and report extract all Release Tasks on any Release 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, Release Definitions, and Release 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

$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
}

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

$uriReleaseDefinitions = $uriReleases + "$($project.id)/_apis/release/definitions?api-version=6.1-preview.4"    $ReleaseDefintionsResult = Invoke-RestMethod -Uri $uriReleaseDefinitions -Method get -Headers $AzureDevOpsAuthenicationHeader    Foreach ($releaseDef in $ReleaseDefintionsResult.value)
{
Write-Host $releaseDef.name
}

4. Definition Get = uses this REST API to get details about Release Definition (Environments, Deploy Phases, and Release Tasks)

$uriReleaseDef = $uriReleases + "$($project.id)/_apis/release/definitions/$($releaseDef.id)?api-version=6.1-preview.4"        $ReleaseDefResult = Invoke-RestMethod -Uri $uriReleaseDef -Method get -Headers $AzureDevOpsAuthenicationHeader        Foreach ($environment in $ReleaseDefResult.environments)
{
Write-Host $environment.name
}

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

6. 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;
  • Release Definition Name (3) = filter report using Release Definition Name field;
  • Release Definitions and Tasks Mapping Information (4) = List all information about Release Tasks, Project Name, Definition Name, and Number of usages from a respective task;
  • Number of usages = Looking at the example above, the Azure Key Vault task is being used 2 times in the Release Definition Sprint 100 RMFeatures.

--

--