Friday, February 29, 2008

Configuring Cruise Control .Net with MsBuild and email notification

Best scenario should
  • Easy to maintain - no extra developer effort should be required
  • Easy to extend - time to time it happens that custom action must be performed during build process
  • Build failure results should be accessible - via mail and on dashbord to decrease time spent looking for error
Possible build scenarions
There are few build scenarios, that could be used with CCNET:
  • Visual studio batch mode
  • Nant compilation
  • MsBuild compilation
I'm going to go fast through first two, and later focus on most suitable ble for me sollution - using msbuild.

Using Visual Studio batch mode
The easiest and fastest to establish way to compile projects is usage of Visual Stuido command line
Adventages:
  • Easy to establish
  • No developer effort required after enviroment configuration
Disadventages:
  • Error report is generated only on local disk, so it's hard for developer to check why it does not compile in build enviroment
  • Standard mail contains only changed files listing
Standard DevEnv configurationMail for devenv task

Using Nant
Nant is another common tool used for building solution, by for me it's biggest disatventage is so uge, that it discards it.
Adventages:
  • Very extensible with plenty of custom task available
  • Tested in Java enviroment
  • Possible to include results in mail
Disadventages:
  • Each developer has to update build script after adding
    • project
    • file to project (it's possible to include **/*.cs but what about *.xml files or not included files)
  • Not so easy to configure first time
For me, forcing developer to update build script is both unsecure and errorprone. In big build enviroments only build master should be resposible for build process. Also it's not obligatory for every developer (like CSS front side developer) to have knowledge about Nant syntax. Mistakes made in build script will fail build process what we should avoid like fire.

Using MsBuild
For me it's most suitable solution and I would strongly recomend it for teams which have quite common build scenarios. In case of some sofisticated build process extension is also possible.
Adventages:
  • Possible to include build results in mail
  • Extensible
  • Easy to maintain - no extra developer effort is required
Disadventages:
  • Takes some time to configure
MsBuild configuration
Follow the instructions from ThoughtWorks blog. They have introduced improved MsBuild logger.
  1. Copy Rodemeyer.MsBuildToCCnet.dll to your \CruiseControl.NET\server folder
  2. Copy msbuild2ccnet.xsl to your \CruiseControl.NET\webdashboard\xsl and \CruiseControl.NET\servrt\xsl folder
  3. Copy cruisecontrol.css to your \CruiseControl.NET\webdashboard folder
    • If you have modified the dashboards stylesheet, just copy the section-project, section-error, section-warning, error and warning style.
  4. In your ccnet.config file locate the task. Change the node to
    c:\Program Files\CruiseControl.NET\ server\Rodemeyer.MsBuildToCCNet.dll

    I highly suggest that you set the verbosity level to quiet or minimal to avoid excessive large log files!

    /v:quiet /noconlog /p:Configuration=Debug
  5. In your dashboard.config file locate the section. Remove the compile-msbuild.xsl and msbuild.xsl if present. Theses transformations are not compatible with the MsBuildToCCNet logger. Add the msbuild2ccnet.xsl transformation instead.
           xsl\header.xsl
    xsl\msbuild2ccnet.xsl
    xsl\modifications.xsl
    [...]
  6. Modify \CruiseControl.NET\server\ccnet.exe.config and \CruiseControl.NET\server\ccservice.exe.config add following lines to add mail sending functionality
  7. Configure project

Sample project configuration
Mail for MsBuild task
Webdashboard output

1 comment:

T0t4r4 said...

In step 6 you did not specified the lines to add for enabling Email sending functionality.