Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity: Disable build trigger for all TeamCity projects

Tags:

teamcity

I would like to ask is there any way to disable build triggers for all TeamCity projects by running a script?

I have a scenario that I need to disable all the build triggers to prevent the builds from running. This is because sometimes, I might need to perform some upgrading process on build agent machines which will take more than one day.

I do not wish to manually click on Disable buttons for every build triggers on every different TeamCity projects. Is there a way to automate this process?

Thanks in advance.

like image 547
IAMbeginner Avatar asked Jan 16 '17 07:01

IAMbeginner


2 Answers

Use Team City REST API.

Given your Team City is deployed at http://dummyhost.com and you enabled guest access with system admin role (otherwise just switch from guestAuth to httpAuth in URL and specify user with password in request, details are in documentation) you can do next:

  1. Get all build configurations GET http://dummyhost.com/guestAuth/app/rest/buildTypes/
  2. For each build configuration get all triggers GET http://dummyhost.com/guestAuth/app/rest/buildTypes/id:***YOUR_BUILD_CONFIGID***/triggers/
  3. For each trigger disable it PUT http://dummyhost.com/guestAuth/app/rest/buildTypes/id:***YOUR_BUILD_CONFIGID***/triggers/***YOUR_TRIGGER_ID***/disabled

See full documentation here

like image 156
Oleksandr Kobylianskyi Avatar answered Sep 20 '22 18:09

Oleksandr Kobylianskyi


You can pause the build queue. See this video. This way you needn't touch the build configurations at all; you're just bringing the TC to a halt.

For agent-specific upgrades, it's best to disable only the agent you're working on. See here.

Neither of these is "by running a script" as you asked, but I take it you were only asking for a scripted solution to avoid a lot of GUI clicking.

like image 30
sferencik Avatar answered Sep 21 '22 18:09

sferencik