In this post I'll introduce the brand new TeamCity.Virtual plugin that supports execution under virtual environments from Vagrant or Docker
Software is the problem
Every build running under CI requires some software/libraries/JVMs/* to be pre-configured on the machine. When your setup has only one build agent everything is simple. But if you need an easy recreatable environment things get more complicated. Every time you need to install some software on every build agent you have to do lots of routine work. When there is a pool of build machines its getting overcomplicated
There exists at least one way to cope with this complexity. Virtual machines. LinuX Containers. Thanks to Vagrant it became an easy, repeatable and scriptable solution. With LinuX Containers (for example Docker) things are even faster
TeamCity.Virtual plugin makes using Docker and Vagrant in TeamCity as easy as using a build runner. So for example, you may run your nodejs builds in a fresh environment of required version without any extra per-agent pre-configuration work
TeamCity.Virtual plugin
The build runner is called Docker / Vagrant. On the runner settings page you may specify the virtual environment configuration to start and the script to execute inside it:
Implementation Details
The plugin works as follows:
- The plugin detects the installed on the build agent Vagrant and/or Docker (so only compatible build agents will be used)
- It starts the virtual environment (box/container) on the build agent
- Mounts the build checkout directory into the started machine
- Maps the working directory into machines path
- Executes the provided script in the started virtual environment in the working directory
- Destroys the environment wiping all the state
Settings
Vagrant box is specified via Vagrantfile. For Docker you need to specify image name only
Run experiments
This is what you see in the build log of Vagrant VM command:
Similar builds under Docker:
What is is for
In the next posts I'll cover details on how to use TeamCity.Virtual plugin to run builds with Nodejs, JVM, Android and much more. Remember, all you need to configure for build agents is Docker or Vagrant. Here are links for publicly available images: Vagrant Boxes and Docker Images
Download and Run
Plugin is implemented under Apache 2.0. Sources are on GitHub. Builds are set up and running in TeamCity.
For more details, see README.md
Your feedback is welcome! Share what you think
comments powered by Disqus