我正在使用 Azure 的 Runs API 来获取管道运行结果,如下所述:
https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/get?view=azure-devops-rest-6.0#runresult
我可以在文档如何获取状态和最终结果,以便我可以知道运行是成功还是失败。但是,如果发生故障,我不知道如何以字符串形式获取该运行中发生的错误。
如何获取导致管道运行失败的实际错误?
I'm using Azure's Runs API to get a pipeline run result as described here:
https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/get?view=azure-devops-rest-6.0#runresult
I can see in the documentation how to get the state and final result so I can know if the run was a success or a failure. However, in case of a failure, I don't see how I can get the error that occurred in that run as a string.
How can I get the actual error which caused the pipeline run to fail?
发布评论
评论(1)
您可以使用 REST API“时间线 - 获取”列出与运行相关的问题(错误和警告)。
注意:
该API只能列出前10个问题。如果运行的问题超过 10 个,则其余问题不会在响应中列出。要获取完整的问题,您可以使用 API“构建 - 获取构建日志”或“日志 - 获取”以获取包含完整问题的完整日志。
[UPDATE]
buildId
与runId
相同,您可以找到它从管道(构建)的 URL 运行。API 请求中不需要
timelineId
,您可以使用如下所示的请求 URI。You can use the REST API "Timeline - Get" to list the issues (error and warning) associated with a run.
Note:
This API can only list the first 10 issues. If the run has more than 10 issues, the rest will not be listed in the response. To get the complete issues, you can use the API "Builds - Get Build Log" or "Logs - Get" to get the complete logs that contains the complete issues.
[UPDATE]
The
buildId
is same as therunId
, and you can find it from the URL of the pipeline (build) run.The
timelineId
is not required in the API request, you can use the request URI like as below.