问题描述
我想通过 REST API 开始构建 Azure Pipelines.有一个 用于排队构建的 API 但我找不到定义变量的方法.
I would like to start a Azure Pipelines build through the REST API. There is an API for queuing builds but I couldn't find a way to define variables.
推荐答案
当您需要在排队时间设置值时,接受的答案并不能真正回答问题.解决方案实际上非常简单,您只需将 parameters
字段添加到 json 有效负载即可.内容应该是包含参数的 json 字符串(不是直接对象)例如:
The accepted answer does not really answers the question when you need to set a value at queue time.The solution is actually pretty simple you just have to add a parameters
field to the json payload. The content should be a json string (not directly an object) containing the parametersEx :
{
"parameters": "{"ReleaseNumber": "1.0.50", "AnotherParameter": "a value"}",
"definition": {
"id": 2
}
}
此功能现在已正确记录为一个可选的字符串化字典
.请参阅 https://www.visualstudio.com/fr-fr/docs/integrate/api/build/builds#queue-a-build
EDIT : This feature is now properly documented as an optional stringified dictionary
. See https://www.visualstudio.com/fr-fr/docs/integrate/api/build/builds#queue-a-build
这篇关于开始构建并通过 Azure DevOps Rest API 传递变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!