Reputation: 717
Is there a way to get information about which stages have failed during a pipeline failure using the Azure Devops REST API or CLI?
Upvotes: 0
Views: 893
Reputation: 19361
If you are using YAML pipeline, you can call Builds-Get rest api first:
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=5.1
In "_links"
you will find timeline
:
"_links": {
"self": {
"href": "https://dev.azure.com/{org}/{proId}/_apis/build/Builds/2703"
},
"web": {
"href": "https://dev.azure.com/{org}/{proId}/_build/results?buildId=2703"
},
"sourceVersionDisplayUri": {
"href": "https://dev.azure.com/{org}/{proId}/_apis/build/builds/2703/sources"
},
"timeline": {
"href": "https://dev.azure.com/{org}/{proId}/_apis/build/builds/2703/Timeline"
},
"badge": {
"href": "https://dev.azure.com/{org}/{proId}/_apis/build/status/29"
}
},
You will get the result of stages from timeline
:
{
"previousAttempts": [],
"id": "d4a9a205-d52e-57fb-7b17-15a9d984af62",
"parentId": null,
"type": "Stage",
"name": "deploy",
"startTime": "2020-03-23T08:42:37.2133333Z",
"finishTime": "2020-03-23T08:42:46.9933333Z",
"currentOperation": null,
"percentComplete": null,
"state": "completed",
"result": "succeeded",
"resultCode": null,
"changeId": 7,
"lastModified": "0001-01-01T00:00:00",
"workerName": null,
"order": 1,
"details": null,
"errorCount": 0,
"warningCount": 0,
"url": null,
"log": null,
"task": null,
"attempt": 1,
"identifier": "deploy"
},
If you want to get the stage status in a release pipeline, you need to use Get Release Environment rest api.
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/Release/releases/{releaseId}/environments/{environmentId}?api-version=6.0-preview.7
Upvotes: 2