Problem Definition
There currently is no API to enable or disable an agent
Suggested Solution
Add an API endpoint to change status of the agent
Workaround
Hit the UI endpoints:
Please note, these are the freemarker actions Bamboo uses internally and are subject to change between versions without any notice
Restart
curl -L -s -u bamboo -p -H "X-Atlassian-Token: no-check" "<bamboo-url>/admin/agent/startAgent.action?agentId=<agent-id>" > /dev/null
Request agent stop
curl -L -s -u bamboo -p -H "X-Atlassian-Token: no-check" "<bamboo-url>/admin/agent/stopAgentNicely.action?agentId=<agent-id>" > /dev/null
Stop immediately
curl -L -s -u bamboo -p -H "X-Atlassian-Token: no-check" "<bamboo-url>/admin/agent/stopAgent.action?agentId=<agent-id>" > /dev/null
Enable agent
BAMBOO_ADMIN= AGENT_ID= curl --user $BAMBOO_ADMIN -H "X-Atlassian-Token: no-check" -H 'Content-Type: application/x-www-form-urlencoded' -X POST '<bamboo-url>/admin/agent/configureAgents!reconfigure.action' \ --data "enableButton=Enable&selectedAgents=$AGENT_ID"
Disable agent
BAMBOO_ADMIN= AGENT_ID= curl --user $BAMBOO_ADMIN -H "X-Atlassian-Token: no-check" -H 'Content-Type: application/x-www-form-urlencoded' -X POST '<bamboo-url>/admin/agent/configureAgents!reconfigure.action' \ --data "disableButton=Disable&selectedAgents=$AGENT_ID"
Alternatively, this third party add-on provides a REST endpoint to enable / disable agents (amongst other things):