Wednesday, October 24, 2007

So What Is Continuous Integration?


In brief, it's the process of integrating the various components of a software project on a regular and frequent basis to enable early detection of problems along component boundaries.

Continuous integration is especially well suited for development teams. Most of us have had the unfortunate experience of working for several days on a key feature until it works perfectly, only to find out that it no longer works with fresh builds of the other components. If we are lucky, the failure will be obvious such as a compiler error. If we're not so lucky, it will appear to work only to fail later during release testing.

Basic Setup of Cruise Control .NET

In the typical configuration you'll get a stand-alone version and a service-based version, along with a Web application that can be used to monitor the build processes.

The stand-alone version, ccnet.exe, is most useful for debugging your configuration script (be sure to stop the CruiseControl.NET service first). You should use the stand-alone version while you are creating or modifying the config file since any errors will be output to the console, and because debugging is very easy and fast. Once the project is building cleanly you can move to using the service binary.

Once installed, the next step is to edit the ccnet.config file. This XML file defines the projects and their options and normally resides in the server directory inside the CCNet installation directory.

Each project that you want to control should be defined using a element.

CCNet has many features and options, but each project boils down to three basic actions:

->get code

->act on code

->report on the results of those actions.

As you can see from the following example, each of these actions maps to an element in the config file.





..list of tasks here..


..list of publishers here..

Starting an Integration

CCNet supports several different methods of determining when to start an integration cycle. This is done using a triggers block. Three different triggers types can be specified.

->An interval trigger element causes an integration to begin a specified number of seconds after the last one finishes.

->A schedule trigger starts integration at a specified time each day.

->A filter trigger specifies a set of times when integration should not start, perhaps due to backup or maintenance.

Here is an example of a trigger block that launches integration five minutes after the last one ends.



The buildCondition attribute value "IfModificationExists" indicates that the integration should only happen if CCNet has detected that source code changes have occurred. A value of "ForceBuild" will build on the given interval in any case.

Getting the Latest Bits


Therefore if CCNet has to check the source code for changes, then we need to tell it what type of source control system we are using and how to access our repository.

To specify the source control settings, use the sourcecontrol element. Consider the following:



svn://svn.myhost.com/example1/trunk
c:\dev\example1
myusername
mypass
false

This fragment specifies that we are using Subversion (type = "svn") and gives the repository URL using the trunkUrl element. The code found at that repository will be checked out and placed in the directory specified with the workingDirectory element. You can use the username and password elements to specify your authentication credentials for the repository. The tagOnSuccess element is used to tag the Subversion repository after a successful integration.

Successful Example with CruiseControl.NET with MSBuild and NUnit testing:

The CCNet.config details:

<cruisecontrol>

<project>

<name>RobotFrameworkname>

<triggers>

<intervalTrigger seconds="100" buildCondition="ForceBuild" />

triggers>

<sourcecontrol type="vss">

<project>$/RobotFrameworkproject>

<workingDirectory>G:\devworkingDirectory>

<username>ajithusername>

<password>ajithpassword>

<ssdir>\\servername\Databse\Workssdir>

sourcecontrol>

<tasks>

<msbuild>

<executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exeexecutable>

<workingDirectory>G:\devworkingDirectory>

<projectFile>RobotFramework.slnprojectFile>

<targets>Buildtargets>

<timeout>15timeout>

<logger>D:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dlllogger>

msbuild>

<nunit>

<path>D:\Program Files\NUnit 2.4.1\bin\nunit-console.exepath>

<assemblies> <assembly>G:\dev\RobotFrameworkTests\bin\RobotFrameworkTests.dllassembly>

assemblies>

nunit>

tasks>

project>

cruisecontrol>

No comments: