VSTS使用API在队列时间设置构建参数 [英] VSTS use API to set build parameters at queue time
问题描述
我需要根据 此答案帮助我对基本构建进行了排队. 我已成功使用个人访问令牌(PAT)进行身份验证并验证了json有效负载
This answer helped me queue a basic build. I have been successful using a Personal Access Token (PAT) to authenticate and this json payload
{
definition: {
id: 19,
}
}
我还需要将变量传递到构建中.这些是我尝试过的一些操作,不起作用
I need to pass variables into the build as well. These are some of the things I have tried that are not working
不工作1
{
definition: {
id: 19,
variables: {
"my.var.one": { allowOverride: true, isSecret: false, value: "stringvalue" },
"my.var.two": { allowOverride: true, isSecret: false, value: "numberValue" }
}
}
}
不工作2
{
definition: {
id: 19,
variables: {
"my.var.one": { value: "stringvalue" },
"my.var.two": { value: "numberValue" }
}
}
}
不工作3
{
definition: {
id: 19,
variables: {
"my.var.one": "stringvalue",
"my.var.two": "numberValue"
}
}
}
有人建议此问题可能有答案,因为VSTS和TFS相似.不幸的是,更改为parameters变量并使用对象的字符串表示形式会得到相同的结果.从参数名称中删除点没有区别.尝试使用API版本3.1也会得到相同的结果.
It was suggested this question might have the answer since VSTS and TFS are similar. Unfortunately changing to the parameters variable and using the string representation of the object gives the same result. Removing the dots from the parameter names did not make a difference. Trying with the API Version 3.1 also got the same result.
不工作4
{
definition: {
id: 19,
parameters: '{
"myVarOne": "stringValue",
"myVarTwo": "numberValue"
}'
}
}
格式化有效负载(或其他位置)中的变量以将其传递到您要排队的构建的正确方法是什么?
What is the correct way to format variables in the payload (or other location) to pass them to the build you are trying to queue?
推荐答案
使用Chrome Developer工具捕获Web UI中QUeue动作的有效负载,我可能会猜测您正在寻找的格式是:
Using the Chrome Developer tools to capture the payload of a QUeue action in the web UI, I'd hazard a guess the format you're looking for is:
{
"queue": {
"id": 1
},
"definition": {
"id": 45
},
"project": {
"id": "a88536a2-a889-45a3-a955-ddf1af8aeba1"
},
"sourceBranch": "refs/heads/master",
"sourceVersion": "",
"reason": 1,
"demands": [],
"parameters": "{\"system.debug\":\"true\"}"
}
这篇关于VSTS使用API在队列时间设置构建参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!