Using CruiseControl.NET Statistics to monitor your code base - From the software development trenches

Using CruiseControl.NET Statistics to monitor your code base

Published 17 May 07 02:37 PM | cjlotz

CruiseControl.NET 1.1 introduced a very nice feature called the Statistics Publisher that you can use to collect and update statistics for each build.  The statistics generated can be very useful for spotting trends in your code base.   If you include the Statistics publisher in your CC.NET config, the statistics can be viewed via the same web dashboard that you use to browse your CC.NET build results. You will find an additional link for every project called View Statistics that links to a web page containing some build statistics for every build of the project you are browsing. 

Out-of-the-box statistics include counters like the number of NUnit tests passed/failed/ignored, FxCop warnings/errors, build times etc.  The statistics shown have limited xml file configurability, but you can add new counters based on xpath expressions to the data contained in your build logs.  To include the NCover and NDepend metrics as well as the Subversion revision number, I added the following statistics to our ccnet.config file for our CodeStatisticsBuild:

1 <statistics> 2 <statisticList> 3 <firstMatch name="Svn Revision" xpath="//modifications/modification/changeNumber" /> 4 <firstMatch name="Coverage" xpath="//coverageReport/project/@coverage" /> 5 <firstMatch name="ILInstructions" xpath="//ApplicationMetrics/@NILInstruction" /> 6 <firstMatch name="LinesOfCode" xpath="//ApplicationMetrics/@NbLinesOfCode" /> 7 <firstMatch name="LinesOfComment" xpath="//ApplicationMetrics/@NbLinesOfComment" /> 8 </statisticList> 9 </statistics> 10

If you are using MbUnit as a test framework and you want to include the MbUnit pass/fail/ignore count, here is the snippet that you need to add to the ccnet.config:

1 <statistics> 2 <statisticList> 3 <statistic name='TestCount' xpath='sum(//report-result/counter/@run-count)'/> 4 <statistic name='TestFailures' xpath='sum(//report-result/counter/@failure-count)'/> 5 <statistic name='TestIgnored' xpath='sum(//report-result/counter/@ignore-count)'/> 6 <statistic name='TestAsserts' xpath='sum(//report-result/counter/@assert-count)'/> 7 <statistic name='TestTime' xpath='sum(//report-result/counter/@duration)'/> 8 </statisticList> 9 </statistics> 10

Since its release the CC.NET community has cottoned onto the feature and there has been one or two very good utilities/extensions written for the statistics publisher. 

  1. The first extension is CCStatistics first created by Grant Drake, the author of the excellent NCoverExplorer, and later updated by Damon Carr to support CC.NET 1.3.  CCStatistics is an application that will parse all your existing build logs and recreate the statistics.  This is useful if you add some additional counters at a later stage and you wish to have your historical build logs also include the new counters. 
  2. The second extension is some very cool graphs for the different statistics created by Eden Ridgway. The old adage "A picture says a thousand words" is so true. 

Hope you find these extensions useful smile_regular

Comments

# Damon Carr said on August 8, 2007 05:07 PM:

Just wanted everyone to know I extended the CCStatistics application and it now works perfectly with 1.3 of CC.NET.

They changed the API so this required some recoding.

Thanks,

Damon Carr, CTO

agilefactor

# cjlotz said on September 1, 2007 03:01 PM:

Damon

I'm very interested in getting hold of the updated source.  I couldn't find a link of your site.  Where can I get hold of it?

Thanks

Carel

# Damon Carr said on September 23, 2007 01:10 AM:

This is now fully available. Everyone can access this here:

www.codeplex.com/ccstatistics

Thanks,

Damon Carr

# From the software development trenches said on November 8, 2007 04:06 PM:

Performance is a very critical non-functional requirement for the SmartClient application that we are

# Part 1: Continuous Integration using MSBuild, CruiseControl.NET, FxCop, NUnit, NCover + Subversion - From the software development trenches said on November 14, 2007 08:49 PM:

Pingback from  Part 1: Continuous Integration using MSBuild, CruiseControl.NET, FxCop, NUnit, NCover + Subversion - From the software development trenches

# Part 5: Continuous Integration - The CodeStatisticsBuild - From the software development trenches said on December 11, 2007 10:41 PM:

Pingback from  Part 5: Continuous Integration - The CodeStatisticsBuild - From the software development trenches

# From the software development trenches said on December 11, 2007 10:43 PM:

This is the seventh post in a series where I document how to setup a Continuous Integration (CI) process

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: