Created
March 27, 2011 22:27
-
-
Save jstangroome/889708 to your computer and use it in GitHub Desktop.
A snippet from an extended DefaultTemplate.xaml TFS 2010 Build Process Template for failing the build when the number of compile warnings increases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Insert this Sequence as one of the last children of the Sequence with DisplayName="Compile and Test" --> | |
<Sequence> | |
<Sequence.Variables> | |
<Variable x:TypeArguments="mtbc:IBuildDetail" Name="LastBuildDetail" /> | |
<Variable x:TypeArguments="x:Int32" Name="LastWarningCount" /> | |
<Variable x:TypeArguments="x:Int32" Name="WarningCount" /> | |
</Sequence.Variables> | |
<Assign x:TypeArguments="mtbc:IBuildDetail" To="[LastBuildDetail]" Value="[BuildDetail.BuildServer.GetBuild(BuildDetail.BuildDefinition.LastBuildUri)]" /> | |
<Assign x:TypeArguments="x:Int32" To="[LastWarningCount]" Value="[Microsoft.TeamFoundation.Build.Client.InformationNodeConverters.GetBuildWarnings(LastBuildDetail).Count]" /> | |
<Assign x:TypeArguments="x:Int32" To="[WarningCount]" Value="[Microsoft.TeamFoundation.Build.Client.InformationNodeConverters.GetBuildWarnings(BuildDetail).Count]" /> | |
<If Condition="[WarningCount > LastWarningCount]"> | |
<If.Then> | |
<Sequence> | |
<mtbwa:WriteBuildError Message="This build has more warnings than the last build. Focus on fixing more build warnings than are introduced." /> | |
<!-- The follow SetBuildProperties line will mark the build as Failed instead of just Partially Successful if the warning count has increased. --> | |
<mtbwa:SetBuildProperties PropertiesToSet="Status" Status="Failed" /> | |
</Sequence> | |
</If.Then> | |
</If> | |
</Sequence> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are a few things that need to be changed for this to work as expected.
First, this doesn't account for any warnings that appear in the "Other Warnings & Errors" section in the build summary. The "LastWarningCount" is the total number of warnings, and the "WarningCount" is only the number of warnings generated from MSBuild.
Second, since a "good build" is one where both "CompilationStatus" and "TestStatus" are "Succeeded", then one of these values needs to be set to "Failed". Otherwise, the next time you queue a build, it will continue to falsely recognize builds that failed due to warnings as the "LastGoodBuild".
So, I would add the following in addition to using "LastGoodBuild":
<mtbwa:SetBuildProperties PropertiesToSet="CompilationStatus" Status="Failed" />