Apr 182018
 
 April 18, 2018  Posted by at 8:44 am Dev Ops  Add comments

Some notes for my colleagues for when I’m not around to manage the pipeline.

For various reasons, mostly lack of time, we have been using just one build agent on our build machine. What a build agent is? Well, on our build machine we run an integration service called TeamCity. This service listens for changes in our GitHub repository and starts some processes when we check in changes. The process is what we refer to as a build configuration(s), and each contains a set of build steps. Think of build steps as ‘jobs’. We used to do this:

On change in the repo (or if triggered manually) we would start the build configuration for our backend services. The things we would do was set the version number, compile the libraries, create deployment packages. If everything went well we would proceed with running our unit tests and integration tests (as a separate build configuration- just think of that as a way of grouping related jobs). If everything passed we would build the client, and if all that was good run the client tests. At the end, we would push the deployment NuGet packages to out deployment service, Octopus.

This is how the chain looked like (simplified):

VCS trigger => Build backend => run tests => build client => run tests => push to Octopus

A build agent is what runs the build steps. And as we only used one it could just run them sequentially, and that would take a fair bit of time. What we have done now is change the build chain and installed more agents, and the client and backend services build steps are run in parallel as the client and backend services and tests are independent of each other. The push to Octopus is only made when and if all the prior builds are successful.
Adding several agents can be a bit tricky (unless somebody has a secret trick), here are the steps:
1. Download the Windows installer
2. Set a new path for the build agent, as well as a new port.

For example, we use: C:\TeamCity\buildAgent1 and C:\TeamCity\buildAgent2
Before we register and start the build agent as a Windows service we need to set some properties- as they all get the same defaults which means that you will only override an existing agent if you don’t. So set a new:
– Name
– Port
This is set here: C:\TeamCity\buildAgent1\conf\buildAgent.properties
And for the service running the agent a new:
– Name
– Title
– Description
– Displayname
This is set here: C:\TeamCity\buildAgent1\launcher\conf\wrapper.conf

Once you have set the properties you got to install, register and start the service.
The bat files that does that are found here:
C:\TeamCity\buildAgent1\bin

Start by uninstalling if the agent is already running, then install, register and start the agent service.

installing-several-build-agents-in-teamcity

You might have to restart the TeamCity service for the changes to take affect (but shouldn’t be necessary).

In TeamCity verify that you can see the agents and that they are compatible with the build configurations.

  2 Responses to “Running multiple build agents in TeamCity”

  1. Interesting, so in order to run multiple agents you need to install the same thing multiple times?

    I haven’t ever used TeamCity but I got curious because it seems like a workaround around a problem that should be trivial (running the same executable multiple times). Or maybe is it that you install it once and make a copy of the directory (which kinda turns the installer into glorified unzipper).

    I hope my question isn’t too dumb 😀

    • Not a dumb question at all!

      Usually you want to install build agents on separate machines (to fully leverage the juice of the machine). But in our case, we just wanted to split up the work to do things in parallel and our machine would have enough hardware to go around for 3 agents. I can image that later this year we will have to change that as our test coverage increases, not to mention when we start doing automated load-testing.

      As for the installer, there is a zip you can download, but you still have to go through the bat files and set up the agent yourself AFAIK. I hope there is a better way, but I haven’t come across one yet :S

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

What is 15 + 12 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)