如何通过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
相关产品推荐
相关产品推荐

