如何使用 Azure 运行 REST API 获取管道运行错误

发布于 2025-01-09 08:52:33 字数 418 浏览 2 评论 0 原文

我正在使用 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一场春暖 2025-01-16 08:52:33

您可以使用 REST API“时间线 - 获取”列出与运行相关的问题(错误和警告)。

注意:
该API只能列出前10个问题。如果运行的问题超过 10 个,则其余问题不会在响应中列出。要获取完整的问题,您可以使用 API“构建 - 获取构建日志”或“日志 - 获取”以获取包含完整问题的完整日志。

[UPDATE]

buildIdrunId 相同,您可以找到它从管道(构建)的 URL 运行。

API 请求中不需要 timelineId,您可以使用如下所示的请求 URI。

GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/timeline/?api-version=6.0

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 the runId, 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.

GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/timeline/?api-version=6.0
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文