是否可以使用Azure Devops REST API或CLI获取有关管道失败期间哪些阶段失败的信息?
答案 0 :(得分:1)
如果您使用的是YAML管道,则可以先调用Builds-Get rest api:
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=5.1
在"_links"
中,您会发现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"
}
},
您将从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"
},
如果要在发布管道中获取阶段状态,则需要使用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