Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making TeamCity FxCop build step cause a build fail if a rule is violated

Tags:

teamcity

fxcop

I have two build steps in my build configuration: Visual Studio (sln) build runner, followed by an FxCop build runner. I'm using TeamCity 6.0.1 and FxCop 10.0.

Out of the box, the FxCop runner in TeamCity seems to only report on rule violations, and produces a report on a Code Inspection tab. I want to ensure that if any violation occurs that the build step fails and thus causes an entire build failure.

Is there a way to accomplish this?

like image 449
Llyle Avatar asked Nov 05 '22 23:11

Llyle


1 Answers

Please set the Errors limit property in your FxCop build step configuration to 0. This should break the build if there is at least one analysis error.

Furthermore, there is a similar Warnings limit property. If you don't want to allow any rule violation at warning level, insert in this field also the value 0. If you want to allow rule violations where the rule attribute BreaksBuild == False, leave this property empty.

I've tried that using TeamCity 6.0 (build 15772) and FxCop 10.0.

[14:39:22]: [Step 2/2] Importing inspection results
[14:39:22]: [Step 2/2] Errors limit reached: found 8 errors, limit 0
[14:39:22]: [Step 2/2] ##teamcity[buildStatus status='FAILURE' text='Errors: 8, warnings: 1']
like image 153
KimCM Avatar answered Dec 06 '22 19:12

KimCM