I'm working on a flow to read the error details from the build pipeline using Azure Devops connector and send an email with failure results.
I'm having trouble parsing the JSON output of build timeline API.
Timeline - Get - REST API (Azure DevOps Build) | Microsoft Learn
The output JSON format has multiple records with taskname, issue, and logs. How do I iterate through it and collect all failure reason in a Variable.
"type": "object",
"properties": {
"records": {
"type": [
"array"
],
"items": {
"type": "object",
"properties": {
...
"details": {},
"errorCount": {
"type": "integer"
},
"warningCount": {
"type": "integer"
},
"url": {},
"log": {
"type": [
"object",
"null"
],
"issues": {
..
}
....
}
}
Example PowerShell code for what I want:
# Get the response from the devops api
$response = Invoke-RestMethod ......
$errors = $response.records.Where({ $_.issues -ne $null })
$errors.ForEach({
# Task name
$_.name
# Error message
$_.issues.ForEach({ $_.message })
})