TeamCity: disable build launch for all TeamCity projects

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

I have a scenario that I need to disable all assembly triggers to prevent assemblies from starting. This is because sometimes I may need to perform some update process on build agent machines that would take more than one day.

I don’t want to manually click the Disable buttons for each build trigger for all TeamCity projects. Is there a way to automate this process?

Thanks in advance.

+4
source share
4 answers

Use the REST Team City API.

, Team City http://dummyhost.com, ( guestAuth httpAuth URL , ), :

  • GET http://dummyhost.com/guestAuth/app/rest/buildTypes/
  • GET http://dummyhost.com/guestAuth/app/rest/buildTypes/id:***YOUR_BUILD_CONFIGID***/triggers/
  • PUT http://dummyhost.com/guestAuth/app/rest/buildTypes/id:***YOUR_BUILD_CONFIGID***/triggers/***YOUR_TRIGGER_ID***/disabled

+5

. . , ; TC.

, . . .

" script", , , , .

+2

The following is an example bash script for mass suspension of all (still not paused) build configurations using the project name template via the TeamCity REST API:

TEAMCITY_HOST=http://teamcity.company.com
CREDS="-u domain\user:password"
curl $CREDS --request GET "$TEAMCITY_HOST/app/rest/buildTypes/" \
| sed -r "s/(<buildType)/\n\\1/g" | grep "Project Name Regex" \
| grep -v 'paused="true"' | grep -Po '(?<=buildType id=")[^"]*' \
| xargs -I {} curl -v $CREDS --request PUT "$TEAMCITY_HOST/app/rest/buildTypes/id:{}/paused" --header "Content-Type: text/plain" --data "true"
+1
source

Another solution might simply be to disable the agent, so the build will no longer be performed.

0
source

Source: https://habr.com/ru/post/1666877/


All Articles