通过API触发Azure Pipelines构建 [英] Trigger Azure Pipelines build via API

查看:88
本文介绍了通过API触发Azure Pipelines构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个有效的Azure管道来构建我的代码库.

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.

谢谢

推荐答案

您可以使用

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

身体

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

请参阅此解决方案

对于第二个问题, 是的,这也是可能的,只需在体内提供参数

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

身体

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

参考

这篇关于通过API触发Azure Pipelines构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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