VSTS 使用 API 在排队时设置构建参数 [英] VSTS use API to set build parameters at queue time

查看:19
本文介绍了VSTS 使用 API 在排队时设置构建参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从 https://docs.microsoft.com/en-us/rest/api/vsts/build/builds/queue?view=vsts-rest-4.1>

这个答案帮助我将基本构建排入队列.我已成功使用个人访问令牌 (PAT) 进行身份验证和此 ​​json 有效负载

<代码>{定义: {编号:19,}}

我还需要将变量传递到构建中.这些是我尝试过的一些不起作用

不工作 1

<代码>{定义: {编号:19,变量:{"my.var.one": { allowOverride: true, isSecret: false, value: "stringvalue" },"my.var.two": { allowOverride: true, isSecret: false, value: "numberValue" }}}}

不工作 2

<代码>{定义: {编号:19,变量:{"my.var.one": { value: "stringvalue" },my.var.two":{ 值:numberValue"}}}}

不工作 3

<代码>{定义: {编号:19,变量:{"my.var.one": "stringvalue","my.var.two": "numberValue"}}}

有人建议这个问题可能有答案,因为 VSTS 和 TFS 是相似的.不幸的是,更改参数变量并使用对象的字符串表示会产生相同的结果.从参数名称中删除点没有任何区别.尝试使用 API 版本 3.1 也得到了相同的结果.

不工作 4

<代码>{定义: {编号:19,参数: '{"myVarOne": "stringValue","myVarTwo": "numberValue"}'}}

格式化负载(或其他位置)中的变量以将它们传递给您尝试排队的构建的正确方法是什么?

解决方案

使用 Chrome 开发人员工具在 Web UI 中捕获队列操作的负载,我猜测您正在寻找的格式是:

POST https://dev.azure.com/jessehouwing/6484ebc3-af16-4af9-aa66-6b3398db7214/_apis/build/builds{队列":{id":27},定义":{id":53},项目":{id":6484ebc3-af16-4af9-aa66-6b3398db7214"},sourceBranch":refs/heads/master",原因":1,要求":[],"参数": "{"system.debug":"true","DefinedVariable":"Override Value"}"

}

I need to queue a VSTS build from the REST API Documented at https://docs.microsoft.com/en-us/rest/api/vsts/build/builds/queue?view=vsts-rest-4.1

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

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" }
        }
    }
}

Not working 2

{
    definition: {
        id: 19,
        variables: {
            "my.var.one": { value: "stringvalue" },
            "my.var.two": { value: "numberValue" }
        }
    }
}

Not working 3

{
    definition: {
        id: 19,
        variables: {
            "my.var.one": "stringvalue",
            "my.var.two": "numberValue"
        }
    }
}

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.

Not working 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?

解决方案

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:

POST https://dev.azure.com/jessehouwing/6484ebc3-af16-4af9-aa66-6b3398db7214/_apis/build/builds
{
"queue": {
    "id": 27
},
"definition": {
    "id": 53
},
"project": {
    "id": "6484ebc3-af16-4af9-aa66-6b3398db7214"
},
"sourceBranch": "refs/heads/master",
"reason": 1,
"demands": [],
"parameters": "{"system.debug":"true","DefinedVariable":"Override Value"}"

}

这篇关于VSTS 使用 API 在排队时设置构建参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆