How to: List all Release Definitions, Stages, and Approvers on Classic Releases in Azure DevOps
This report will show in Power BI all Release Definitions, Stages, and Approvers.
DISCLAIMER: To create this report, the stages on Azure Pipelines have been defined as DEV, TEST, and PROD, representing the delivery flow of applications in Azure DevOps. This report only covers Classic Releases Definitions (not YAML Multi-Stage Pipelines).
An original script is available on my GitHub repository. See below this script:
Let’s go understand each command used.
- PowerShell script will receive the following parameters:
- $PAT = Personal Access token to connect on Azure DevOps;
- $Organization = Organization URL to list all Release Definitions, Stages, and Approvers;
- $Connstr = connection string to Azure SQL Database to store 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. az devops project list — use this command to list all projects on Azure DevOps organization
$ProjectsResult = az devops project list --org $Organization | ConvertFrom-Json
Foreach ($project in $ProjectsResult.value)
{
Write-Host $project.name
}
3. az pipelines release definition list — use this command to list all Release Definitions on respective organization and project
$ReleaseDefinitionResult = az pipelines release definition list --org $Organization --project $project.name | ConvertFrom-Json Foreach ($releaseDef in $ReleaseDefinitionResult)
{
Write-Host $releaseDef.name
}
4. On this script, pieces of information about Release Definition was brought, among which stand out:
- Stage Name = Stage name in Release Definition;
- Pre-Deployment Approvals = if this stage requires pre approvers, it will be listed all approvers (users or groups);
- Post-Deployment Approvals = if this stage requires post approvers, will be listed all approvers (users or groups).
5. After executing the script on PowerShell, these informations are stored in a table in Azure SQL.
6. After insert informations into a table, I connected this database on Power BI:
- Projects (1) = filter projects on organization;
- Releases (2) = filter release definitions;
- Release Definition (3) = list all Release Definitions;
- Stage (4) = list all stages belong to this Release Definition;
- Pre-deployment Approvals (5) = list all users and groups that approve this stage;
- Post-deployment Approvals (6) = list all users and groups that approve this stage.