本文介绍了启动构建并通过Azure DevOps Rest API传递变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过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.

推荐答案

当您需要在队列时间设置值时,接受的答案并不能真正回答问题.该解决方案实际上非常简单,您只需要向json有效负载添加一个parameters字段即可.内容应为包含参数的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
                   }
}

此功能现已正确记录为an optional stringified dictionary.请参阅 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传递变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 20:25