Running multiple TeamCity Agents on the same computer?
Asked Answered
Y

3

87

We have several build machines, each running a single TeamCity build agent. Each machine is very strong, and we'd like to run several build agents on the same machine.

Is this possible, without using virtualization? Are there quality alternatives to TeamCity that support this?

Yelena answered 24/11, 2009 at 10:31 Comment(0)
F
134

Yes, it's possible:

Several agents can be installed on a single machine. They function as separate agents and TeamCity works with them as different agents, not utilizing the fact that they share the same machine. After installing one agent you can install additional one, providing the following conditions are met:

  • the agents are installed in the separate directories
  • they have distinctive work and temp directories
  • buildAgent.properties is configured to have different values for name and ownPort properties

Make sure, there are no build configurations that have absolute checkout directory specified (alternatively, make sure such build configurations have "clean checkout" option enabled and they cannot be run in parallel).

Under Windows, to install additional agents as services, modify [agent dir]\launcher\conf\wrapper.conf to change the properties to have distinct name within the computer:

  • wrapper.console.title
  • wrapper.ntservice.name
  • wrapper.ntservice.displayname
  • wrapper.ntservice.description
Fidel answered 24/11, 2009 at 11:11 Comment(7)
Just a remark, but keep in mind there is little benefit to doing this if your agent machine does not have the resources necessary. For example, a single-core VM won't work through a build queue with three agents much faster than it will with one.Chaucerian
If you've gone and installed your agents without knowing the above (like I did), run "service.uninstall.bat" on the installed Build Agent in the /bin directory, then do what the above answer says for each agent. After that, run "service.start.bat" on each agent.Clockmaker
Brilliant. But strange that installing multiple agents isn't supported by the installation wizard.Disapproval
It's good to be advise that you may have an issue with the new agent after installing it, an error like "Teamcity agent in disconnected state (Agent has unregistered (will upgrade))". This can be solved stopping the fisrt agent(or the other agents installed) and restarting the new from the services (on Windows/Windows Server). This will set your new agent from Disconnected to Connected.Gal
Attention: "If you use Windows installer to install additional agents and want to run the agent as a service, you will need to perform manual steps as installing second agent as a service on the same machine is not supported by the installer: the existing service is overwritten". See confluence.jetbrains.com/display/TCD10//…\Wile
Too bad they haven't fixed the installer to support this even after all these years. Had to experience it the bad way shutting down the current build agent.Activist
You mention that work and temp directories have to be independent for each agent, but can they share the system directory?Indomitable
T
30

You could also take a look at this blog post for Step-by-step guide

http://handcraftsman.wordpress.com/2010/07/20/multiple-teamcity-build-agents-on-one-server/

Thinker answered 12/4, 2012 at 22:51 Comment(1)
I am glad this blog post has helped some people. However, following the directions in it ruined my existing service. Even after a complete uninstall of both services, deleting the two directories, and reinstalling only the original service, it still won't run some jobs that were working fine before I started all this. I highly recommend the solution from the top-voted answer.Lynnelynnea
A
3

The top answer is the correct method, but if you want to complete this more easily you can use the TeamCityAgent Chocolatey package and supply the agent name, the agent folder and the port as --params and it will handle setting up the config files as well as pulling in the required version of Java via the server-jre package.

The one caveat to this is you need to use --force on any installs after the first agent as Chocolatey doesn't currently understand installing the same application with a different configuration as a "new" installation.

You will also need to use --version 2.0.1-beta-05 since this is still in a testing phase, but should make it out of beta soon.

Full install example for a second agent: choco install teamcityagent --force -y --params 'serverUrl=http://teamcity.local:8111 agentName=AgentUno agentDir=C:\buildAgentUno ownPort=9091' --version 2.0.1-beta-05

Alexisaley answered 23/12, 2016 at 16:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.