使用 REST API 向 TeamCity 中的构建配置添加触发器 [英] Adding a Trigger to a build configuration in TeamCity using the REST API

查看:39
本文介绍了使用 REST API 向 TeamCity 中的构建配置添加触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 TeamCity 的 REST API 来创建新的构建配置.为了避免手动完成所有操作,我使用 TeamCitySharp.

I'm trying to use TeamCity's REST API to create a new Build Configuration. To avoid doing everything manually I'm using TeamCitySharp.

我能够创建构建配置,将其附加到模板,甚至设置参数而没有出现重大问题.但是现在我正在尝试设置构建触发器,而 TeamCitySharp 需要原始 xml 来进行触发器配置?任何人都可以在这里指出正确的方向吗?不知道从哪里开始.我查看了 JetBrains 站点上的 REST API 文档,但没有详细说明.

I was able to create a build configuration, attach it to a template and even set parameters without major issues. But now I'm trying to setup build Triggers and TeamCitySharp requires the raw xml for the trigger configuration? Anyone could point me in the right direction here? Not sure where to start. I've looked over the REST API documentation on the JetBrains site but it doesn't go into the specifics.

使用普通 REST API 的示例就可以了,不需要使用 TeamCitySharp.

An example using the plain REST API would be fine, it doesn't need to be using TeamCitySharp.

谢谢!

推荐答案

我找到了答案.我使用 Postman 对已经配置了触发器的 BuildType 执行 GET:

I found the answer. I used Postman to do a GET on a BuildType that already had a Trigger configured:

http://teamcity:8111/httpAuth/app/rest/buildTypes/id20_mybuild

在响应中,您将获得完整的配置,包括触发器的 XML.因此,使用 TeamCitySharp 创建触发器将如下所示:

In the response you get the full config, including the XML for the Trigger. So, using TeamCitySharp, creating a trigger would look like this:

string xml = @"<trigger id=""TRIGGER_1"" type=""buildDependencyTrigger"">
                 <properties>
                    <property name=""dependsOn"" value=""id31_MyProject_SomeBuild""/>
                 </properties>
               </trigger>";

client.BuildConfigs.PostRawBuildTrigger(BuildTypeLocator.WithId("NewBuild"), xml);

这篇关于使用 REST API 向 TeamCity 中的构建配置添加触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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