【问题标题】:In Azure DevOps REST Api how to get the build variables of the given build?在 Azure DevOps REST Api 中如何获取给定构建的构建变量?
【发布时间】:2022-02-16 23:51:08
【问题描述】:

使用 REST API,我可以轻松获取与给定构建对应的对象。但是在该构建排队时,它被赋予了构建变量。有些是在排队时设置的,有些是从构建定义继承的。

到目前为止,我还没有弄清楚如何评估这些构建变量。构建对象似乎不包含它们。

我可以清楚地看到parameters 属性中的顶级模板参数。但是构建变量在哪里?

编辑 1

我们使用 Azure DevOps 2020 的本地版本。它支持的最高 api 版本是 6.1-preview,并且该版本中的“Runs - Get”似乎没有太多回报。请注意:

C:\> Invoke-RestMethod "$TfsInstanceUrl/DFDevOps/_apis/pipelines/$($b.definition.id)/runs/$($b.id)?api-version=6.1-preview" -UseDefaultCredentials


_links       : @{self=; web=; pipeline.web=; pipeline=}
pipeline     : @{url=https://tdc1tfsapp01.dayforce.com/tfs/DefaultCollection/d85566a3-9e95-4891-9fd8-42750a0bc250/_apis/pipelines/8781?revision=19; id=8781; revision=19;
               name=PRBuild Stress Test; folder=\}
state        : completed
result       : succeeded
createdDate  : 2022-02-11T15:57:07.4271331Z
finishedDate : 2022-02-12T00:46:22.6090285Z
url          : https://tdc1tfsapp01.dayforce.com/tfs/DefaultCollection/d85566a3-9e95-4891-9fd8-42750a0bc250/_apis/pipelines/8781/runs/1399783
resources    : @{repositories=}
id           : 1399783
name         : 20220211.2



C:\>

这是否意味着这些变量仅在 Azure DevOps Services 中可用?

【问题讨论】:

    标签: azure-devops-rest-api


    【解决方案1】:

    您可以尝试使用 API“Runs - Get”来获取构建。

    通常,在此 API 的响应正文中,您会看到管道变量列在 variables 对象中。

    【讨论】:

    • 请参阅EDIT 1
    猜你喜欢
    • 2019-10-14
    • 1970-01-01
    • 2019-08-24
    • 1970-01-01
    • 2020-01-13
    • 2016-03-24
    • 1970-01-01
    • 2019-06-09
    • 2023-03-14
    相关资源
    最近更新 更多