Trigger Azure Pipelines build via API

懵懂的女人 提交于 2020-01-11 12:55:33

问题


I made a working Azure Pipeline to build my codebase.

Looking for a way to trigger the Azure Pipelines build via API, ideally REST. If REST is not possible, perhaps I could try invoking the build via Azure Functions using a resource ID of sorts. I would like my own repository monitor to issue an API request that would trigger the build when my conditions are met. Another question - is it possible to set "pipeline variables" via API - e.g. I make an API call passing values to be used as my pipeline variables' values then triggers the build.

Thank you


回答1:


You can use the VSTS REST API to queue the build by giving the ID

POST:

https://account.visualstudio.com/project/_apis/build/builds?api-version=4.1

Body

{ 
        "definition": {
            "id": number
        } 
}

Refer to this solution

For your second question, Yes this is also possible, Just giving the parameters within the body

Body

{
    "parameters":  {"Parameter1":  "a value"},
    "definition":  {
                       "id":  2
                   }
}

Reference



来源:https://stackoverflow.com/questions/52718462/trigger-azure-pipelines-build-via-api

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