In Azure DevOps you can get a nice overview about failed and succeeded stages for a certain build, under the following url:
https://dev.azure.com/{organization}/{project}/_build?definitionId=xxxxx
I inspected the network traffic in the browser, but couldn't find the API calls to get the information on the "Runs" tabpage.
Does anybody know what api('s) to call to get this information based on a known build definitionId?
You can get each step
, job
, stage
item running status via Timeline Get.
function Get-AdoToken {
param (
[string]$UserName,
[string]$PersonalAccessToken
)
$basicAuth = ("{0}:{1}" -f $UserName, $PersonalAccessToken)
$basicAuth = [System.Text.Encoding]::UTF8.GetBytes($basicAuth)
$basicAuth = [System.Convert]::ToBase64String($basicAuth)
$headers = @{Authorization = ("Basic {0}" -f $basicAuth) }
return $headers
}
$userName = 'anything' # do not change this value.
$adoPAT = ''
$orgName = '' # org name -- fill-in
$projectName = '' # project name -- fill-in
$runId = '2952' # build id -- fill-in
$timelineId = '0' # do not change this value.
$headers = Get-AdoToken -UserName $userName -PersonalAccessToken $adoPAT
$uri = 'https://dev.azure.com/{0}/{1}/_apis/build/builds/{2}/timeline/{3}?api-version=7.1' -f $orgName, $projectName, $runId, $timelineId
$res = Invoke-RestMethod -Uri $uri -Method 'Get' -Headers $headers
$res | ConvertTo-Json -Depth 10
My test result: only highlight the stage
item