Manage Agents
This article lists REST API requests concerning agents.
List agents (only authorized agents are included by default) |
GET http://<TeamCity URL>:<port>/app/rest/agents
|
List all connected authorized agents |
GET http://<TeamCity URL>:<port>/app/rest/agents?locator=connected:true,authorized:true
|
List all authorized agents |
GET http://<TeamCity URL>:<port>/app/rest/agents?locator=authorized:true
|
List all enabled authorized agents |
GET http://<TeamCity URL>:<port>/app/rest/agents?locator=enabled:true,authorized:true
|
List all agents (including unauthorized) |
GET http://<TeamCity URL>:<port>/app/rest/agents?locator=authorized:any
The request uses default filtering (depending on the specified locator dimensions, others can have default implied value). To disable this filtering, add |
Enable/disable an agent |
PUT http://<TeamCity URL>:<port>/app/rest/agents/<agentLocator>/enabled
Put |
Authorize/unauthorize an agent |
PUT http://<TeamCity URL>:<port>/app/rest/agents/<agentLocator>/authorized
Put |
Get/put an agent's single field |
GET/PUT http://<TeamCity URL>:<port>/app/rest/agents/<agentLocator>/<field_name>
|
Delete a build agent |
DELETE http://<TeamCity URL>:<port>/app/rest/agents/<agentLocator>
|
Add a comment when enabling/disabling and authorizing/unauthorizing an agent | Agent enabled/authorized data is exposed in the <agent id="1" name="agentName" typeId="1" connected="true" enabled="true" authorized="true" uptodate="true" ip="..........." href="/app/rest/agents/id:1">
<enabledInfo status="true">
<comment>
<user username="userName" id="1" href="/app/rest/users/id:1"/>
<timestamp>20160406T175040+0300</timestamp>
<text>newcomment</text>
</comment>
</enabledInfo>
<authorizedInfo status="true">
<comment>
<user username="userName" id="1" href="/app/rest/users/id:1"/>
<timestamp>20160406T183033+0300</timestamp>
</comment>
</authorizedInfo>
....
</agent>
On curl -v -u user:password --request PUT "http://<TeamCity URL>:<port>/app/rest/agents/id:1/enabledInfo" --data "<enabledInfo status='false'><comment><text>commentText</text></comment></enabledInfo>" --header "Content-Type:application/xml
|
Agent Pools
List all agent pools |
GET http://<TeamCity URL>:<port>/app/rest/agentPools
|
Get/modify/remove an agent pool with |
GET/PUT/DELETE http://<TeamCity URL>:<port>/app/rest/agentPools/id:ID
|
Add an agent pool |
|
Move an agent to the pool from the previous pool |
|
Example:
Assigning Projects to Agent Pools
Add a project to a pool |
|
Delete a project from a pool |
DELETE http://<TeamCity URL>:<port>/app/rest/agentPools/id:XXX/projects/id:YYY
|