views:

167

answers:

2

I would like CruiseControl.Net to fail a build when some code metrics change in a 'wrong' direction, i.e. code coverage decreases or Gendarme defect count increases. The Gendarme metrics are already tracked in report.xml file (because they are presented on web dashboard graphs), the code coverage is only reported on build status page (and saved in build report xml).

How can I achieve this?

A: 

The basic principle is to store the metric score and the date somewhere (e.g. a database) and check the metric against the most recent stored value each time.

Your main problem would be collecting the stats on the new build before success/failure point - the publishers run after the build has already succeeded/failed, so you would need to use a sequential task to gather the stats.

Come to think of it, I'm not really sure it's a great idea to actually fail a build based on metrics, you might find this will come back to bite you.

Colin Pickard
A: 

Whatever you do, it should be a part of your build script, not the CC.Net project integration. Why? Because otherwise developers will not be able to detect such build failures before they commit the code to the repository. You should strive to have the same build script running both on the build server and developers' machines. There isn't much point in having a build server with half of your builds marked as failed.

So you would have to keep these stats' history yourself and then compare the latest stats with historical ones using your build script.

Igor Brejc