我正在使用 rest api 从 azure devops 收集一些信息。我想获得包括每个阶段在内的完整构建结果。但在文档中,它是不可用的。简单的构建 api 调用只能给我有限的数据。是否有任何方法可以收集阶段性信息,如阶段是否成功或每个阶段的开始和结束时间。
将会很感激你的帮助。
你应该首先调用这个网址。
https://dev.azure.com/<YourOrg>/<Your-project>/_apis/build/builds/<buildid>?api-version=5.1
在链接中,你会发现时间轴。
"_links": {
"self": {
"href": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/Builds/460"
},
"web": {
"href": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_build/results?buildId=460"
},
"sourceVersionDisplayUri": {
"href": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/builds/460/sources"
},
"timeline": {
"href": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/builds/460/Timeline"
},
"badge": {
"href": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/status/30"
}
},
在那里你会找到你要找的东西。
{
"previousAttempts": [],
"id": "67c760f8-35f0-533f-1d24-8e8c3788c96d",
"parentId": null,
"type": "Stage",
"name": "A",
"startTime": "2020-04-24T08:42:37.2133333Z",
"finishTime": "2020-04-24T08:42:46.9933333Z",
"currentOperation": null,
"percentComplete": null,
"state": "completed",
"result": "succeeded",
"resultCode": null,
"changeId": 12,
"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": "A"
},