Azure devops 通过REST API或CLI使用Azure Devops访问管道故障阶段信息

Azure devops 通过REST API或CLI使用Azure Devops访问管道故障阶段信息,azure-devops,Azure Devops,是否有方法使用Azure Devops REST API或CLI获取管道故障期间哪些阶段失败的信息?如果您使用的是YAML管道,可以先调用REST API: GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=5.1 在“\u links”中,您将发现时间线: "_links": { "self": {

是否有方法使用Azure Devops REST API或CLI获取管道故障期间哪些阶段失败的信息?

如果您使用的是YAML管道,可以先调用REST API:

GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=5.1
“\u links”
中,您将发现
时间线

"_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"
        }
    },
         {
            "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"
        },
您将从
时间线
中获得阶段结果:

"_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"
        }
    },
         {
            "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"
        },
如果希望在发布管道中获取阶段状态,则需要使用RESTAPI

GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/Release/releases/{releaseId}/environments/{environmentId}?api-version=6.0-preview.7

谢谢你的回答。时间线正是我想要的!