While developing software products with a complicated structure, you come at some moment to the necessity of automating the processes of building and integrating the projects and distribution kits being developed. Continuous integration is the practice of software development that implies frequent (up to several times during the day) automatic build and testing of the current product version. This approach enables you to reduce the labor intensiveness of the integration as such and detect its defects and conflicts at the very early stages. Note that this methodology implies using a version control system (for example, CVSNT and Subversion) to store the source codes and all the other components needed to build and test the project.
Earlier, when we were developing the static code analyzer PVS-Studio to search for 64-bit and parallel errors, we solved this task with the help of script files of Windows command line. Although this technique seems to be the simplest and require no specialized tools, using it inevitably involves some issues:
To solve these problems we decided to use a specialized platform to provide continuous integration - CruiseControl.NET. The build system was to be able to fulfill the following tasks:
CruiseControl.NET is a package of applications the most important of which is the automatic integration server. While watching the version control system the CruiseControl.NET server can detect changes in the repository and automatically launch the integration build of the project to verify these changes. The local version of the system repository will be adjusted in accordance with the latest revision of the version control system, that is, all the files that have been changed since the last successful build will be updated. Besides, CruiseControl.NET has a powerful system of triggers (a set of conditions fulfillment of which initiates the integration server to start building the project) you may manage the time of starting the build with:
When the build is over, the system server will inform the developer about its results and publish them. Of course, you may start building any project manually. Usually the integration server is located on a special separate computer whose configuration fits the environment where a project will be arranged to the maximum degree. The result of only this kind of build may be considered final.
Below is a layout of continuous integration system server arrangement:
You may manage the build server through a special configuration XML file. It has the name ccnet.config by default and is situated in the same folder as the server is. At the highest level of this file are queues of integration and projects of integration while all the other settings are described at the sublevels of separate projects. There may be a lot of projects and they may or may not be allowed to build simultaneously and depending on each other - this is determined by how they are arranged in the integration queues. Several queues may be built simultaneously while the projects inside them only sequentially.
Each project is a set of various integration tasks, triggers to launch it and a block that defines the parameters of interaction between the server and the version control system. Each of these blocks is described at the corresponding project sublevels. The tasks themselves are split into 3 blocks: preceding the build, involved into the build as such and following the build. These tasks are separate actions (such as executing a command in the command line, running tests or publishing the build results) that compose the process of project integration. CruiseControl.NET provides you with many different methods to build a project:
The build of a separate project is considered successful only if all the tasks of the second (building) block are fulfilled. CruiseControl.NET provides you also with a large number of result publication methods:
In addition to the automation server, the package CruiseControl.NET provides you with the tools CCTray and Web Dashboard. CCTray is a Windows utility that rests in the notification area and shows the build status on a remote server. With its help you may watch the status of several builds on different servers simultaneously and make any server start building. Web Dashboard is a web-application for IIS server. It serves to display the build data through the web-interface. With its help you may display the data from different servers.
The benefit of introducing such a system is evident. First of all it provides smooth integration of the whole project. Integration of different modules and revisions made by different programmers goes automatically and if something goes wrong you immediately learn about it. Moreover, continuous integration is useful not only when monitoring the development process at the current moment but when analyzing the tendencies as well. But we should note that the process of automatic integration also requires constant adjustment in correspondence with the changes introduced into the projects being built.