TeamCity Dynamic Build Agents

Kamlesh Bhatt
kamlesh_bhatt
Published in
3 min readSep 25, 2019

--

TeamCity provides the Docker Wrapper extension for Command Line, Maven, Ant, Gradle, and since TeamCity 2018.1, .NET CLI (dotnet) and PowerShell runners. This extension allows running a build step inside the specified docker image. Each of the supported runners has the dedicated Docker settings section.

Requirements

The integration requires Docker installed on the build agents. Docker Compose also needs to be installed to use the Docker Compose build runner.

Supported Environments

TeamCity-Docker support can run on Mac, Linux, and Windows build agents. It uses the 'docker' executable on the build agent machine, so it should be runnable by the build agent user.

Icon

  • On Linux, the integration will run if the installed Docker is detected.
  • On Windows, the integration works for Linux and Windows container modes.
  • On macOS, the official Docker support for Mac should be installed for the user running the build agent.

Since version 2018.2, TeamCity has switched from Oracle Java to OpenJDK 8 (by AdoptOpenJDK). All Docker images have been updated to support OpenJDK.

Building Simple NodeJs App — Example

The following example is just a demonstration of the above theory. We intend to build a node js application with a docker image.

Now login to your TeamCity instance and Create a sample project, and then Create Build configuration then select the Runner type as command line.

In the commands to run in custom script section, and in the docker setting the image you want to run your build step with in this case node.

Once done run the build. TeamCity will first pull the image that you have specified in the build configuration and then run the custom script provided. Please check below images for the same. After the build is completed, it will print the node version.

Conclusion

Using this TeamCity feature, you can be really creative, you don’t need to build additional build agents rather use this to build your projects with any dependencies.

You can also build your custom image(which has all the dependencies like maven, ant, node installed) and use this for building your project.

--

--

Kamlesh Bhatt
kamlesh_bhatt

4x AWS Certified | DevOps Engineer | GCP | Azure | Cloud Platform Engineer | Docker | Kubernetes