You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过REST API获取Azure DevOps运行时参数?

获取Azure DevOps YAML管道运行时参数的官方API方案

你提到的YAML中定义的运行时参数(如下示例):

parameters:
- name: testParameter
  displayName: Parameter
  type: string
  values:
  - 'test1'
  - 'test2'

确实无法通过默认调用GET https://{host}/{organization}/{project}/_apis/pipelines/{pipelineId}或GET https://{host}/{organization}/{project}/_apis/build/definitions/{definitionId}返回,但可以通过以下两个官方公开的REST API获取,无需依赖隐藏接口:

  • Build Definitions API(带扩展参数)
    调用时添加$expand=processParameters查询参数,使用7.1-preview.7及以上版本的API:

    GET https://{host}/{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=7.1-preview.7&$expand=processParameters
    

    返回结果的processParameters字段会包含所有运行时参数的完整配置,包括名称、显示名、类型、可选值等信息。

  • Pipelines API(预览版本)
    使用预览版API并添加$expand=parameters参数:

    GET https://{host}/{organization}/{project}/_apis/pipelines/{pipelineId}?api-version=7.1-preview.1&$expand=parameters
    

    接口返回数据中的parameters数组会直接列出所有运行时参数的详细定义。

上述两个接口均为Azure DevOps官方文档收录的公开接口,稳定性和兼容性有保障,无需使用未公开的Contribution/HierarchyQuery接口。

内容的提问来源于stack exchange,提问作者McBodik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 05:07:22