We have some TeamCity build agents running and I'd like to destroy and rebuild all agents over night automatically to have a clean set of agents in the morning. Destroying and provisioning the agent isn't a problem but I can't find a way to authorize the fresh agents automatically. The TeamCity documentation talks about the web UI only which is a pretty bad starting point for automation.

Anyone got a solution for this?


You can use the official plugin for this purpose https://confluence.jetbrains.com/display/TW/Agent+Custom+Token+Authorize+Plugin

Unfortunately, it allows only one agent per token, but that is a good point to start. There are also unofficial plugins like https://github.com/matt-richardson/TeamCityAgentAutoRegisterPlugin that allow automatic authorization of more the one agent per token


I'm trying to do exactly that, and from what I understood, we need our provisioning system to maintain the file at <build_agent_work_dir>/conf/buildAgent.properties with the same content across restarts.

Reference: https://confluence.jetbrains.com/display/TCD9/Build+Agent+Configuration


Teamcity does not provide automatic agent authorization other than UI but if you are using same server/host names you can try by backing-up and restoring of agent.properties file as specified by Marcel. this file will have the authorization key of the agent

as rightly pointed, documentation link has just UI level authorization, no CLI or plugins and is hard way to do it in bulk

from Documentation:

they are authorized in the TeamCity web UI.

The agent running on the same computer as the server is authorized by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.