Checkout on Agent Tricks

In this post I'll describe how to implement checkout on agent for Git or Mercurial without installing them to each build agents.

Suppose you have a build configuration with Git or Mercurial VCS root and checkout on agent enabled. Such build configuration requires you have Git or Mercurial installed on the agent. There are 2 different solutions to that:

Install DVCS for each agent manually

The obvious way to do it is to install a software on each agent manually. It will work brilliant if you have fewer that 5 agents.

If there are more agents, you may create another build configuration that may install the software. Thanks to Custom Run Dialog you may schedule the configuration to run on all agents. It's recommended to add a reboot (or agent restart) command to the end of the script to make agent sync with new environment.

This approach can hardly work for Amazon EC2 setups. State of EC2 agents is usually lost on shutdown.

Install Software on Demand

Let's make TeamCity install the software on demand. First, say you have configuration A that requires a peace of software. You create configuration PRE with scripts to install the software. On settings of configuration A create dependency to configuration PRE with Run on the same agent option.


I have a set of Amazon EC2 agents running Ubuntu. Unfortunately, there is no Mercurial available on the machines. Every time EC2 S3 agent is shutdown the machine state is lost. My build script requires .hg directories under checkout to work with Mercurial Mq extension. So I created a configuration that calls the script with help of Command Line build runner:

and specified it to be started on the same agent before the actual build

comments powered by Disqus