我的Azure管道yaml中有一个步骤,要求第一个失败步骤的步骤号。有没有办法检索此信息(最好是在bash任务中)?
想法是检索失败步骤 ... / _ apis / build / builds / 777777 / logs / 3
的日志答案 0 :(得分:1)
我不擅长bash脚本编写,但您需要:
https://dev.azure.com/{{organization}}/{{project}}/_apis/build/builds/3477/timeline?api-version=6.0
其中3477
是您的构建ID。
result=failed
查找第一条记录:{
"previousAttempts": [],
"id": "5caf77c8-9b10-50ef-b5c7-ca89c63e1c86",
"parentId": "12f1170f-54f2-53f3-20dd-22fc7dff55f9",
"type": "Task",
"name": "Run a multi-line script",
"startTime": "2020-09-07T12:00:04.5033333Z",
"finishTime": "2020-09-07T12:00:04.7466667Z",
"currentOperation": null,
"percentComplete": null,
"state": "completed",
"result": "failed",
"resultCode": null,
"changeId": 10,
"lastModified": "0001-01-01T00:00:00",
"workerName": "Hosted Agent",
"order": 4,
"details": null,
"errorCount": 1,
"warningCount": 0,
"url": null,
"log": {
"id": 7,
"type": "Container",
"url": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/builds/3477/logs/7"
},
"task": {
"id": "d9bafed4-0b18-4f58-968d-86655b4d2ce9",
"name": "CmdLine",
"version": "2.164.2"
},
"attempt": 1,
"identifier": null,
"issues": [
{
"type": "error",
"category": "General",
"message": "Bash exited with code '1'.",
"data": {
"type": "error",
"logFileLineNumber": "15"
}
}
]
},
"log": {
"id": 7,
"type": "Container",
"url": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/builds/3477/logs/7"
},