【问题标题】:Not getting full pipeline run information through the Azure DevOps API未通过 Azure DevOps API 获取完整的管道运行信息
【发布时间】:2021-02-10 15:22:33
【问题描述】:

为了解决这个问题Creating a dashboard for the last branch deployed through pipelines,我想我会尝试使用 Azure DevOps API。它在大多数情况下都可以正常工作,但是我观察到 GET Run API 不会返回多存储库管道的所有存储库信息 (https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/get?view=azure-devops-rest-6.0)。它似乎只返回self repo 的数据。例如,我的一次运行的响应负载如下所示:

    "resources": {
        "repositories": {
            "self": {
                "repository": null,
                "refName": "refs/heads/master",
                "version": "commit-hash"
            }
        }
    },

尽管有几个其他 repos 正在检查中。这是一个错误还是预期的?有解决办法吗?

谢谢!

【问题讨论】:

  • 您好,刚刚检查一下这个问题现在是否仍然阻碍您?这个问题有更新吗?
  • 嗨。是的!我能够使用它。谢谢。
  • 嗨@AlexDenton,很高兴听到您的问题已经解决,请问accept it as the answer 好吗?因此,它可以帮助遇到相同问题的其他社区成员,我们可以存档此线程。谢谢。祝你今天过得愉快。 :)

标签: azure-devops azure-devops-rest-api


【解决方案1】:

我们可以通过 F12 获取 REST API,这个 REST API 是https://dev.azure.com/{Org name}/{Project name}/_build/results?buildId={Build ID}&__rt=fps&__ver=2

Power shell 脚本:

cls

$connectionToken="{PAT}"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
$URL = "https://dev.azure.com/{Org name}/{Project name}/_build/results?buildId={Build ID}&__rt=fps&__ver=2"
$Result = Invoke-RestMethod -Uri $URL -Headers @{authorization = "Basic $base64AuthInfo"} -Method Get 
Write-Host "This build sources are"$Result.fps.dataProviders.data."ms.vss-build-web.run-details-data-provider".repositoryResources.alias

结果:

注意:这个 yaml 文件保存在 repo sample 中,self repo 是 sample repo

【讨论】:

    猜你喜欢
    • 2021-09-09
    • 1970-01-01
    • 2020-12-15
    • 2020-02-13
    • 2021-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多