Wednesday, March 4, 2009

Building a Continuous Integration Server

Continuous integration refers to the practice of frequently integrating developers code with the code that is already released.  It has a number of advantages for a small development team in that:

  1. All check-in are checked against the existing code base
  2. It allows for additional checks such as Unit Tests, code compliance and others to be run automatically.
  3. It provides developers in the team with instant feedback when errors occur on any application.
  4. It assists in the release of applications as everything is packaged on the build server and scripted correctly.
  5. As builds are taken only from a source control database, it ensures that all information and scripts have been stored before an application can be released.

Installation on the server

To run a continuous integration build server you need the following applications installed.

Windows 2003 Server R2
IIS
Visual Studio 2008
Source Safe Client
.Net Framework 3.5
Cruise Control.net
CCNetConfig

Assuming that the server has been built using the standards set down the additional tools are installed as follows:

CruiseControl.Net

Run the executable that is downloaded from SourceForge.

image

Click “Next”, click “I Agree” to the licence agreement and Next selecting all default components.

image

Select both options and click Next.

image

Set the destination folder and click Next and finally click “Install”

image

Once installation has completed click “Next” and click Finished.

CruiseControl.Net

Run the executable that is downloaded from CodePlex.

 image

Click Next and accept the licence agreement and click “Next”.

image

Set the destination folder and click “Next” and finally click “Install”.

image

Once installation have completed click “Finish”.

Configuration of the build projects

Each application should have it’s own project within the CruiseControl.Net application.  Each project is basically a set of tasks which are described using XML and stored in the CCNet Server Configuration file.  These files can get quite long and complicated, which is the reason we use the CCNetConfig application which provides a simple point and click interface.

Open the CCNet Config application, using Start/All Programs CCNet Config/CCNetConfig.

image

When the application starts choose file/Open from the menu and browse to the location of the CruiseControl directory.  Within the server folder you’ll find a file called ccnet.config, select this file and set the version combo box to the version of CruseControl you are using.  In this case it was 1.4 and click “Open”.

image

Assuming you’re starting for the first time you will only see two entries in the tree, select the first “CruiseControl” and click the first icon in the tool bar to create a project.  You will see a dialogue appear, in which you enter a meaning name for the project you’re trying to place in continuous integration.  In this case I’m using “Debug – CryRptCom” which is a debug build of a small Visual Studio 2008 project.  Click OK and the entry should appear in the tree on the left.

image

Once the project is created expand the tree node and the select Tasks node and fill in the required information such as the working directory for the project, account to access SrouceControl, etc. 

Note: Create a folder named “buildlogs” folder in the working directory selected or the build will fail.

Once that has been completed right click the Triggers node and and select “Add Trigger/IntervilTrigger”.

image

Enter the information needed to trigger a build, in this case If a change exists in source Control and wait 120 seconds before testing for the next change.

Once that has been completed right click the Tasks node and and select “Add Task/Visual Studio Task”.

image

Enter the information needed to build the code Using Visual Studio 2008.

Starting the CruiseControl Service

Once the project has been configured you need to start (or restart)  the CuriseContorl service in order for the changes to be read.

image

From the Control Panel/Administrative Tools, select Services and select the CruiseControl.Net, then click the Start icon on the tool bar.  the Service should start without any errors.

 

Accessing Cruise Control from a developers client

The Cruise Control application creates a website by default which is used to interacted with the client application.  In this case the development server URL is http://miranda/CCnet/

image 

You should see the project you have entered into the configuration screen.  Now you can click the “Force” button to build the application on the server.  This will get the latest version of the application from source control, download it to the server and build everything.  If it passes all the test correctly it will show a green “Success” message in the last build status column.

image

The process is also running continually, so if any developer tries to check in code which does not compile for example as I did here be commenting out a sting.

image

After a few seconds the CruiseControl will report the error.

image image

Click on the project link to get the error message… and as you can see “rgreene” was the last person to access the files and you also see the comment used for the check-in.  After fixing the error and checking in you will see that the project goes back to green status.

No comments: