How to: Process Templates, Work Item Types and Custom Rules Mapping on Azure DevOps
This script and report extract all Inherited Process Templates, Work Item Types and Custom Rules within the Azure DevOps organization
Many customers that use Azure DevOps prefer to change System Process Templates (Agile, Basic, Scrum, and CMMI), thus creating your own process using a feature Customize Process Templates. Therefore, it’s possible to create new work item types, fields, rules, etc.
But when you have different Process Templates, Work Item Types, and Rules, it is often necessary to identify where each rule is used, to understand your own process. Thinking about mapping these rules on Azure DevOps, the following report was created:
The original script is available on my GitHub repository. See below this script:
Let’s 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 Process Templates, Work Item Types and Custom Rules;
- $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:
2. Process List = uses this REST API to list all Inherited Process Templates on Azure DevOps organization
$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($PAT)")) }$UriOrganization = "https://dev.azure.com/$($Organization)/" $uriProcess = $UriOrganization + "_apis/work/processes/"$processesResult = Invoke-RestMethod -Uri $uriProcess -Method get -Headers $AzureDevOpsAuthenicationHeader$inheritedProcess = $processesResult.value | Where-Object {$_.customizationType -eq 'inherited'}if ($inheritedProcess.Count -gt 0)
{
Foreach ($process in $inheritedProcess)
{
Write-Host $process.name
}
}
3. Work Item Types List = uses this REST API to list all Work Item Types on each Inherited Process Template
$uriWorkItemTypes = $uriProcess + "$($process.typeId)/workitemtypes/"$workItemTypesResult = Invoke-RestMethod -Uri $uriWorkItemTypes -Method get -Headers $AzureDevOpsAuthenicationHeader Foreach ($wit in $workItemTypesResult.value)
{
Write-Host $wit.name
}
4. Rules List = uses this REST API to list all Custom Rules on each Work Item Type
$uriRules = $uriWorkItemTypes + "$($wit.referenceName)/rules?api-version=6.0-preview.2" $rulesResult = Invoke-RestMethod -Uri $uriRules -Method get -Headers $AzureDevOpsAuthenicationHeader $customRules = $rulesResult.value | Where-Object {$_.customizationType -eq 'custom'} if ($customRules)
{
Foreach ($rule in $customRules)
{
Write-Host $rule.name
}
}
5. After extract all Inherited Process Templates, Work Item Types and Custom Rules, this information is stored in a table in Azure SQL.
6. After insert information into a table, connect this database on Power BI:
- Process Template (1) = Filter report using Process Template field;
- Work Item Type (2) = Filter report using Work Item Type field;
- Process Templates, Work Item Types and Custom Rules (3) = List all information about Process Template, Work Item Type, Custom Rule Name, Condition Type, Condition Field, Condition Value, Action Type, Action Field, and Action Value.