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

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.

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

Thanks!

有帮助吗?

解决方案

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

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);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top