Disable/Enable Agent Through REST API?

Hi,

The subject says it all.  Can an agent's status be changed via the REST API?

-T

9 comments
Comment actions Permalink

There is no such feature yet, but you can make HTTP call as explained in this thread.
We have this feature request in TW-8394, please vote.

0
Comment actions Permalink

Hello Tennis,

in TeamCity 7.0, it will be possible to enable/disable agent by sending true/false via PUT request to http://<teamcity_server_url>/httpAuth/app/rest/agents/<agentLocator>/enabled

0
Comment actions Permalink

Hi, I'm trying to take advantage of this feature on TeamCity 7.03 and although I can get the api to tell me if a given server is enabled or not, I can't craft the put request to disable it, can you be a little more specific on how to do this please?  I figure I'm doing something a little daft, but I can't for the life of me work it out.

This tells me if the agent id 3 is enabled:

http://teamcity/httpAuth/app/rest/agents/id:3/enabled

And I get true if it is and false if it's not.  What I want to do is set it, not get it.

Thanks, Jeremy.

0
Comment actions Permalink

Jeremy,

With curl that would be
curl -v --basic --user USERNAME:PASSWORD --request PUT "http://teamcity/httpAuth/app/rest/agents/id:3/enabled" --data false --header "Content-Type: text/plain"
for disabling the agent, and
curl -v --basic --user USERNAME:PASSWORD --request PUT "http://teamcity/httpAuth/app/rest/agents/id:3/enabled" --data true --header "Content-Type: text/plain"
for enabling.

0
Comment actions Permalink

It seems my problem is due to a template configuration having the agent definition.  If I try to change the agent for the build that inherits from the template I get an 'requirement for parameter with name 'projectTypes'  already exists.'  If I detatch it from the template then is works.

0
Comment actions Permalink

You seem to try to modify agent requirements, which is a bit different thing from agent enabling/disabling, so this might deserve a different thread. The message you receive is most probably the same you would get if you try to do that from UI.

0
Comment actions Permalink

Sorry posted in wrong thread, will update original.


http://devnet.jetbrains.net/message/5466350#5466350

0
Comment actions Permalink

Is there a way to set the disable/enable reason through the REST api?

0
Comment actions Permalink

Please watch/vote for this feature request. Current workaround is to perform the request to the server like browser does:

http://localhost:8111/httpAuth/ajax.html?reason=<comment>&changeAgentStatus=<agentId>&enable=true

0

Please sign in to leave a comment.