Looking for a build activity which breaks a build when new warnings are introduced

Mar 7, 2012 at 8:40 PM

We're attempting to clean up a big bunch of brown field code, while at the same time a team is adding new functionality. We'd like to make sure changed and new code is cleaned from any compiler/code analysis or other warnings, but there's too many of them to begin by cleaning up the current solution.

So the following was proposed:

  • Write/select a build activity which compares the list of warnings in the build against the lines of code that changed with that check-in.
  • If the warning provides a line number, and that line number was changed, fail the build.

I understand this will not find all new warnings and things introduced in other parts of the code will not be flagged, but it's at least something. It works even on incremental builds

Another option that was proposed:

  • Compare the list of warnings of the previous known good build against the list of this build. If there are new warnings (track on file name level), fail the build.

This might work not work if the Clean Up action  is set to none and I doubt it'll be easy to match the warnings against eachother.

Any known Actions out there that might provide said functionality? If not, I'd like it :). I've read that Hudson has said feature where you can even define a Threshold to distinguish between stable and unstable builds or complete build failure.

And we're getting similar requests for Code Coverage. Ensure that coverage of changed code is going up. It looks like we might be able to use the NDepend action for that soon. And it might be enough to simply flag the average totals going down.

See also: http://stackoverflow.com/questions/9607356/looking-for-a-build-activity-which-breaks-a-build-when-new-warnings-are-introduc

Mar 8, 2012 at 2:52 PM

One of the inputs on the custom activity should specify the "threshold" for whether or not to explicitly "break" the build directly from the activity.  In the code for the activity, if the threshold value is met somehow (e.g. StyleCop warnings, etc), then set the Build Status to failed. 


More importantly, in your build template, you can put the entire activity in a try catch flow, and if anything is caught, you can fail the build.



Many different ways of doing it.