Scripting out the installation of Team City agents

automated-installteamcity

We have a reasonable-sized Team City installation and currently I am planning to add another 25 agents, 5 agents per machine. So far I was doing the installation manually:

  1. Log into the server
  2. Download and run agentInstaller.exe, add the agent number to the name
  3. Open a command prompt as administrator and run the script to install the service (given a service name with the agent number appended)
  4. Open the Services configuration settings, change the user that the service is running as and start the service

Is there a simple way to script as many of these steps as possible? Ideally I would like to log into the box, and run a single script with agent number to do steps 2-4.

Best Answer

How about making Chocolatey do this:

cinst TeamCityAgent -params 'serverurl=http://servername:8081 agentName=Build1'

It seems that you still have to open firewall ports, though. This is from Asger Hallas's comment in the link above:

New-NetFirewallRule -DisplayName "Allow TeamCity" -Direction Inbound -Protocol TCP -LocalPort 9090 -Program "c:\program files\java\jre7\bin\java.exe" -Action Allow

The installation of Chocolatey itself is a PowerShell one-liner, too:

iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))

I have yet to find a way for a scripted installation of the TeamCity server, though.