通过 API 触发 Azure Pipelines 构建 [英] Trigger Azure Pipelines build via API
问题描述
我制作了一个可用的 Azure Pipeline 来构建我的代码库.
I made a working Azure Pipeline to build my codebase.
正在寻找一种通过 API(最好是 REST)触发 Azure Pipelines 构建的方法.如果无法使用 REST,也许我可以尝试使用各种资源 ID 通过 Azure Functions 调用构建.我希望我自己的存储库监视器发出一个 API 请求,该请求将在满足我的条件时触发构建.另一个问题 - 是否可以通过 API 设置管道变量" - 例如我进行了一个 API 调用,传递值用作我的管道变量的值,然后触发构建.
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.
谢谢
推荐答案
您可以使用 VSTS REST API 或 DevOps REST API 通过提供 ID 将构建排入队列
You can use the VSTS REST API or DevOps REST API to queue the build by giving the ID
VSTS 发布:
https://account.visualstudio.com/project/_apis/build/builds?api-version=4.1
DevOps 发布:
https://dev.azure.com/account/project/_apis/build/builds?api-version=6.1-preview.6
身体
{
"definition": {
"id": number
}
}
对于你的第二个问题,是的,这也是可能的,只需在正文中给出参数
For your second question, Yes this is also possible, Just giving the parameters within the body
DevOps 主体
{
"parameters": "{"Parameter1": "a value"}",
"definition": {
"id": 2
}
}
注意:对于这些 API 调用,请确保使用基本身份验证并传递个人访问令牌作为值
这篇关于通过 API 触发 Azure Pipelines 构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!