Using CruiseControl.NET Statistics to monitor your code base
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.
- 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.
- 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 