Configuring CruiseControl.Net with SVN, Visual Studio 2008 and MSBuild
July 23, 2010 2 Comments
Integrating CruiseControl.Net into our development environment was a fairly simple process. The steps below detail what was required to get CruiseControl.Net to pull changes from SVN, on an interval trigger, then build using Visual Studio 2008 via MSBuild.
For details on configuration options for CruiseControl, refer to the online documentation.
Installing CruiseControl.Net
1. Download the latest installation files. The latest release at the time of this article is 1.5.725.
2. Run the installation file and place the files in the default directory C:\Program Files\CruiseControl.NET.
CruiseControl.Net Overview
CruiseControl can run either as a stand-alone exe or by running as a service. It’s important to run the stand-alone application when building your config file at first. The exe will run in a command window displaying everything that’s happening within your CruiseControl.Net server. It’s an essential tool to debugging your config file.
Stand alone application is located in: C:\Program Files\CruiseControl.NET\server\ccnet.exe
The CruiseControl.Net service is named CruiseControl.Net Server (in Control Panel/Administrative Tools/Services)
Editing Your Configuration File
1. Open CruiseControl.Net’s main configuration file
Locate file ccnet.config in C:\Program Files\CruiseControl.NET\server.
2. Add your project
<project name="Public Website">
<workingDirectory>d:\build\trunk\Website</workingDirectory>
<webURL>http://server1/ccnet/server/local/project/testProject/ViewLatestBuildReport.aspx</webURL>
<triggers>
<intervalTrigger name="continuous" seconds="30" buildCondition="ForceBuild" initialSeconds="30"/>
</triggers>
...
</project>
The project contains the following tags:
- <workingDirectory> – The directory CruiseControl.Net will use to manage your project.
- <webURL> – The build report for the project you’re configuring.
- <triggers> – How often CruiseControl will pull down files from source control and build the solution. The example above has an interval trigger of 30 seconds. Every 30 seconds CruiseControl will check source control for modifications. If they exist, a build will be triggered.
3. Define SVN as your Source Control
<sourcecontrol type="svn">
<trunkUrl>https://MyServer/svn/website/trunk</trunkUrl>
<workingDirectory>d:\build\Website</workingDirectory>
<username>dave</username>
<password>dave123</password>
<timeout units="minutes">30</timeout>
</sourcecontrol>
Within the <sourcecontrol> tag, our SVN configuration is defined:
- <trunkUrl> – Location of the main trunk for our project.
- <workingDirectory> – Directory to place all files pulled down from SVN when doing a build.
- <username> / <password> – SVN credentials
4. Add an MSBuild task
A basic MSBuild task is below, essentially building our solution from the command prompt using Visual Studio. Build options used are debug and rebuild all.
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>D:\build\Website</workingDirectory>
<projectFile>MyWebSolution.sln</projectFile>
<buildArgs>/p:Configuration=Debug /v:diag /t:rebuild</buildArgs>
<timeout>120</timeout>
</msbuild>
</tasks>
5. Configure Notifications
CruiseControl.Net does a great job of notifying when builds break. The CCTray, CruiseControl’s notification icon stays in the bottom right-hand corner of your desktop in your system tray. Your icon turns green on successful builds, yellow when building and red when the build fails.
If this isn’t enough, you can setup email notifications. If you work in an environment where you have outsourced development, it helps to send out instant notifications if someone breaks the build.
<publishers>
<xmllogger logDir="D:\build\Website\BuildLogs" />
<email mailport="25" includeDetails="TRUE">
<from>no-reply@wordpress.com</from>
<mailhost>mail.MyServer.com</mailhost>
<users>
<user name="Dave" group="BuildGuru" address="david.scott.peterson@gmail.com" />
</users>
<groups>
<group name="BuildGuru">
<notifications>
<notificationType>Failed</notificationType>
<notificationType>Fixed</notificationType>
<notificationType>Exception</notificationType>
</notifications>
</group>
</groups>
</email>
</publishers>
Server Configuration
The CruiseControl.Net service needs to run as an account that has access to the source code repository. Since our source control is listed under HTTPS, but with no valid SSL certificate, we have to convince CruiseControl to ignore the certificate error. The CruiseControl.Net user account needs to permanently accept the certificate exception, otherwise, CriuseControl will fail to pull down the latest code from SVN.
Steps to creating the CruiseControl.Net service account:
1. Create a CruiseControl.Net local user account.
2. Setup service to run as new CruiseControl.Net local user account.
3. Accept SSL exception for CruiseControl.Net local user account.
Login to the server hosting CruiseControl.Net using the account created in step 1. Open a command prompt and type: ‘svn list https://<svn repository location>’. When prompted to accept the certification exception, type ‘p’ for permanently.
Full CCNet.config
<cruisecontrol>
<!– This is your CruiseControl.NET Server Configuration file. Add your projects below! –>
<!– Trunk –>
<project name=“My Website“>
<workingDirectory>d:\build\trunk\Website</workingDirectory>
<webURL>http://server1/ccnet/server/local/project/testProject/ViewLatestBuildReport.aspx</webURL>
<triggers>
<intervalTrigger seconds=“30“ buildCondition=“IfModificationExists“/>
</triggers>
<sourcecontrol type=“svn“>
<trunkUrl>https://MyServer/svn/website/trunk</trunkUrl>
<workingDirectory>d:\build\Website</workingDirectory>
<username>dave</username>
<password>dave123</password>
<timeout units=“minutes“>30</timeout>
</sourcecontrol>
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>D:\build\Website</workingDirectory>
<projectFile>MyWebSolution.sln</projectFile>
<buildArgs>/p:Configuration=Debug /v:diag /t:rebuild</buildArgs>
<timeout>120</timeout>
</msbuild>
</tasks>
<externalLinks>
<externalLink name=“My Website“ url=“http://MySite.com“ />
</externalLinks>
<publishers>
<xmllogger logDir=“D:\build\Website\BuildLogs“ />
<email mailport=“25“ includeDetails=“TRUE“>
<from>no-reply@wordpress.com</from>
<mailhost>mail.MyServer.com</mailhost>
<users>
<user name=“Dave“ group=“BuildGuru“ address=“david.scott.peterson@gmail.com“ />
</users>
<groups>
<group name=“BuildGuru“>
<notifications>
<notificationType>Failed</notificationType>
<notificationType>Fixed</notificationType>
<notificationType>Exception</notificationType>
</notifications>
</group>
</groups>
</email>
</publishers>
</project>
</cruisecontrol>
Pingback: Tweets that mention Configuring CruiseControl.Net with SVN, Visual Studio 2008 and MSBuild « Everything Web -- Topsy.com
Pingback: Integrating Selenium Tests into CruiseControl.Net via NUnit « Everything Web