11 min read

(For more resources related to this topic, see here.)

Continuous Integration

Continuous Integration is defined by Martin Fowler as follows:

Continuous Integration is a software development practice where members of a team integrate their work frequently; usually each person integrates at least daily — leading to multiple integrations per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible. Many teams find that this approach leads to significantly reduced integration problems and allows a team to develop cohesive software more rapidly.

Kent Beck and Martin Fowler are credited as the first users of the term Continuous Integration since 1999. Now, more than 10 years later, this term has become a well-known and well-used practice (though many interested parties might wish it would turn into an established standard) used for software design and engineering across the entire industry.

The main essence of it lies in the simple practice of each delivering person in the team to meet on a very frequent, several-times-per-day basis to a source control repository.

In the long run, this could save us from lots of headaches and last-minute integrations made in a rush. The more frequent this integration is, the less chance you have to get an incompatible bunch of modules instead of a rock solid application.

Okay, so now you are delivering to a repository every so often but what next? Repository integration will keep the code consistent, but will it check the code for correctness or run some tests? The answer here is no. What we need at this time is some build automation, and here TeamCity steps in.


Let’s sum up some outstanding TeamCity features.

Automatic and manual build triggering

Do you want every change in the Version Control System (VCS) to be verified? It’s never been easier. Just set up automatic build triggering on every commit and you are done. Also dependent builds could be instantly triggered after the completion of some other build and may even use their generated artifacts. At any time, we can schedule a manual build by simply clicking on the Run button.

Pre-tested commit

This concept also has another name — remote run. It is really a life saver when we wish to check the consistency of our patch with the whole project. Instead of performing a commit, we select Remote run on the commit screen and can decide whether to do an actual commit depending on build results. It is usually not a good idea to proceed with a commit if the build is either failed or did not introduce new failures itself, but kept previous ones in place.

Instant notifications

There are plenty of different ways to stay in touch with the TeamCity Server. On the other hand, it could be as simple as sending an e-mail to all interested parties and as exquisite as the Windows tray notifier. Many other options such as RSS feeds, Jabber , and plugins for major IDEs are supported.

Code coverage and inspections

Upon producing build results we may be interested in checking our code coverage. Further on, it is possible to apply over 600 IntelliJ IDEA’s inspections in order to find actual and potential problems. Inspections result in thorough reports for probable bugs, performance issues, and obsolete code, if present.

Easy to verify code changes

No longer does the developer need to remember what the code looked like before a change had been introduced. TeamCity provides a very useful and effective comparison engine to easily see what actually has been modified with which changes.

Configurable test reports

You need not to wait for a long build run just to figure out that the very first test has failed. TeamCity will notify you at once when it notices a failing build. You will get a complete report showing which tests have failed, whether this problem has happened for the first time, and so on, with the full statistics the developer needs.

Comprehensive build infrastructure

TeamCity supports multiple multi-platform build agents which can be run in parallel independently of each other. It is possible to get workload information and history. Every bit of statistics related to builds is also accessible over time. It is possible to track build progress, run build chains, and apply enhanced build dependencies.

Enhanced VCS integration

TeamCity permits utilizing sophisticated VCS configuration . It can use a smart scheduling mechanism called quiet period, if there is a need not to run builds at once, but to wait until partial commits or ones from different roots are conducted. Agent-side checkout allows maintaining source code consistency over your builds spread between different build agents.

Advanced features

TeamCity provides flexible user management with the possibility of configuring per-project user roles and accesses along with user action audits. TeamCity supports adaptable user authentication with LDAP and NT authentication s upport, detection of hanging builds that take longer time than expected, discovery of JVM out-of-memory crashes, and on the fly thread dumps for running builds.

Terms and concepts

Let’s look at some useful concepts that will help you understand TeamCity better.

Build agent

A build agent is an isolated software unit where actual builds are executed and run. A build agent can coexist with the TeamCity server on one physical box, however that is not required. It is possible to install two or more build agents on one machine though it is not the preferred way to go because of the performance impact those agents would have on each other:

Sometimes separate build agents are needed per platform. For instance, it is often a situation that the server and the default agent are running on a Linux machine. Let’s say there’s a need to run some very specific kind of test such as GWT or flexunit tests on a build agent but this is impossible on a default one because these tests cannot be run in headless mode (it means display-less mode in which Linux servers usually work). A possible solution here is to install another build agent on the Windows machine. A build agent is a stateful machine. In order to make it work, the developer needs to install and run it first. At that point, the agent becomes disconnected. Then, during the configuration stage, we provide a connection link to the TeamCity server and the agent gets connected. It is still not yet ready because we need to make it authorized first. This is done manually on the Agents page. The default agent on the same machine as the server gets authorized automatically. At any point, you may disable or enable a particular build agent.

Build artifact

Every build may be configured to produce one or more build artifacts. They could be described as simple files that are possible to download or use in other (dependent) builds. For instance, the coverage data generated by a build is a build artifact. Also it could be some generated JAR, WAR, or other file that is configured.

There are also so-called hidden build artifacts that enlist raw coverage data and maven build data. These could be accessed through a special link.

Build configuration

In a nutshell, this is a set of actions to be applied to the source code. You define the actions and rules to be applied to the build, and click on Run ; the configured builds would be handled by TeamCity and could be run from this point continuously and automatically. Creation of a build configuration is pretty straightforward and consists of several steps. On the first one, the name should be provided along with the rules describing how to understand if a build was successful or not. The later steps allow configuring version control settings, setting up build steps (Maven, Ant, and many other options are available). Then you can build triggering rules, dependencies, and other additional settings.

Upon creation of one build configuration, it could be replicated to avoid entering the configuration data many times in a row. Even a simple setting such as a user or group notification rule can be reused.

If you feel you are going to need the same build configuration several times, you may create a build configuration template. After that, you can generate new configurations with a single click — only the name of the template needs to be provided and the rest of the data would be served by the template.

Each build configuration has its state — active or paused. Also, it has a completion status that can be either successful, failed, or under investigation, indicated by the corresponding icon. Before the build has been run for the first time, there’ll be no icon, as the status is still unknown.

Every build configuration has a unique ID, which you may refer to when performing some advanced manual configuration of TeamCity.

Code coverage

Code coverage is a very useful measure to describe the degree or level of how well and thoroughly the source code is covered by unit tests. This term really deserves a separate book to be written about it, though none are written yet. However, there are plenty of articles available on the Internet describing best practices. A nice start would be from the following example:


There are many metrics that could be collected with powerful code coverage engines, TeamCity being one of them. Combined with the Sonar code inspection server (sonarsource.org) code coverage steps up to the next level where possible performance issues can be detected early on, probable bugs can be caught, or direct misuse of some language functions can be spotted.

TeamCity supports coverage engines for both Java and .NET. Major build runners that support code coverage collection include Maven, Ant, NAnt, NUnit, and several more.

At the time of writing, TeamCity did not support full coverage for integration tests. For example, having several Maven modules and calling one module from another will collect coverage for only the initiator module. In order to obtain this kind of coverage, the Sonar server with the Cobertura analysis tool would be needed.

My Changes

My changes is a special page where personal historical build information concerning a specific user is collected. Here, a user may observe his own changes and figure out how they affected builds presented by a timeline. You may go as far as viewing atomic change details presented by each build. Also the developer may navigate from here to the issue tracker directly, if issue tracker integration is turned on and properly configured.


TeamCity can utilize several notifiers. There can be either separate or common notification rules created for each of the supported notifiers. The total list includes:

  • Email notifier undoubtedly being the most commonly used one

  • IDE notifier shows status in your favorite IDE

  • Jabber notifier sends events through Jabber server, that is Google Talk

  • System Tray notifier displays updates in the Windows system tray

  • Atom/RSS feed notifier informs you via Atom/RSS feed

Settings are configured on the My Settings & Tools page in the Watched Builds and Notifications section.

Pre-tested commit (remote run)

This delayed commit is a very powerful feature which previously allowed TeamCity to stand out in the crowd. By now, it has been adopted by major competitors as it became very useful, and therefore, popular. In short, it allows a developer to make sure that his changes will compile without problems and pass all tests, not only on his box but on at least one isolated machine.


A project is the largest separate TeamCity’s concept used here. It is merely a group of build configurations. It should have its own name, some meaningful description and may be used to define some generic security settings for all included build configurations. You can assign separate permissions for users on a per — project basis.

Version Control System

A Version Control System ( VCS) is a facility to store a project’s source code files and all changes made to them over time. It is expected that the VCS will represent corresponding versions of code for any given time. These slices are called revisions and are usually identified by incrementing numbers. TeamCity supports plenty of version control systems such as ClearCase, CVS , Git , Mercurial, Perforce, StarTeam , Subversion , Team Foundation Server , SourceGear Vault , and Visual SourceSafe .


TeamCity is a contemporary, rich-featured, distributed build management and Continuous Integration server. It has been designed for developers and by developers, thus being very intuitive, easy to use, easy to learn, and user friendly. There’s absolutely nothing hard to understand neither in lifecycle, organization, or total workflow of TeamCity.

TeamCity contains an extensive set of utilities which moves your development effectiveness and comfort to a totally new level. It is a light and very easy to install facility which provides you with a decent degree of certainty that the code in your version control system not only compiles, but even adheres to written tests. And all this magic happens automatically on a continuous basis without requiring any user intervention. Every change in your source code would be detected, monitored and inspected, and you shall get full report about every modification introduced.

Resources for Article :

Further resources on this subject:

Subscribe to the weekly Packt Hub newsletter

* indicates required


Please enter your comment!
Please enter your name here