Pause builds with REST API calls


I must have the syntax wrong, I have tried to pause a build with the following REST API calls with no success:

wget http://<user>:<password>@teamcity:8111/httpAuth/action.html?pauseComment=RestAPITest&pauseBuildType=<BuildId>&pause=true

curl -v -u <user>:<password> http://teamcity:8111/httpAuth/action.html?pauseComment=RestAPITest&pauseBuildType=<BuildId>&pause=true

I have TeamCity 8.1.5 installed.

Can someone tell me the correct syntax for this?



Comment actions Permalink

Hi Dave,

You are trying to use browser calls which are stricktly speaking not part of our REST API. You can use an HTTP sniffer to get the exact form of the request sent by the browser when pausing a build configuration from web UI.

The recommended approach however is to use REST API way for that.

That will be somehting like
curl -v -u <user>:<password> http://teamcity:8111/httpAuth/app/rest/buildTypes/(id:RestAPITest)/paused --header "Content-Type: text/plain" --data "true"

While not related to your question let me note that is is probbaly woth it to upgrade ot the latest (9.0.4 as of now) to get access to lots of fixes and load of new features.

Comment actions Permalink

Thanks Yegor.

When I ran it like this, it worked fine:

Pause build:

curl -v -u <user>:<password> -X PUT http://teamcity:8111/httpAuth/app/rest/buildTypes/<BuildId>/paused --header "Content-Type: text/plain" --data "true"

Unpause build:

curl -v -u <user>:<password> -X PUT http://teamcity:8111/httpAuth/app/rest/buildTypes/<BuildId>/paused --header "Content-Type: text/plain" --data "false"

As to upgrading the TeamCity server: if it were up to me I would upgrade each time. I hope to upgrade soon.



Please sign in to leave a comment.