Start a build and passing variables through VSTS Rest API

这一生的挚爱 提交于 2019-12-17 12:11:09

问题


I would like to start a Visual Studio Team Service build through the REST API. There is an API for queuing builds but I couldn't find a way to define variables.


回答1:


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 parameters Ex :

{
    "parameters":  "{\"ReleaseNumber\":  \"1.0.50\", \"AnotherParameter\":  \"a value\"}",
    "definition":  {
                       "id":  2
                   }
}

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




回答2:


Variables are included in definitions, you can update your build definition to set the variables via build-definition api first and then queue the build.

Following is the variable section get via build-definition api:

  "variables": {
    "system.debug": {
      "value": "false",
      "allowOverride": true
    },
    "BuildConfiguration": {
      "value": "release",
      "allowOverride": true
    },
    "BuildPlatform": {
      "value": "any cpu",
      "allowOverride": true
    }
  },


来源:https://stackoverflow.com/questions/34343084/start-a-build-and-passing-variables-through-vsts-rest-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!