Issues with build failure in Team Foundation Server 2012

Deepak Mittal, Support Escalation Engineer, brings his experience on issues with TFS 2012 Build failure

Problem Description:

Whenever the build fails it throws the following error: 

TF42097: A work item could not be created due to a field error. The following fields have incorrect values: Field: 'Severity' Value: '1 - Critical', Field: 'Symptom' Value: '', Field: 'Steps To Reproduce' Value: '', Field: 'Bug Source' Value: '', Field:'Screen/Module' Value:

Root cause:

1. Basically build failure creates a bug workitem and assigns values to files(some are not required, whereas some are and for rest we define the value in the build template).

2. In your bug.xml, the fields 'Symptom' ,'Steps To Reproduce', 'Bug Source', 'Screen/Module' are added newly which are not by default part of the bug
workitem type.

3. Also, you have defined these fields as required field in workitem, so whenever build is trying to create a bug workitem, it is failing as no value is assigned to them.

4. And for Severity field, the default value which we have in build template is more there in your workitem, you have changed those names as per your requirement.

 Solution:

1. Checkout the build template from TFS source control.

2. Find the place in the build definition where the work item is created. You can find it here in the Default Template: Sequence –> Run on Agent –> Try Compile, Test, and Associate Changesets and Work Items –> Sequence –>Compile, Test, and Associate Changesets and Work Items –> Try Compile and Test –> Compile and Test –> For Each Configuration in BuildSettings.PlatformConfigurations –> Compile and Test for Configuration–> If BuildSettings.HasProjectsToBuild –> For Each Project in BuildSettings.ProjectsToBuild –> Try to Compile the Project –> Exception–> Handle Exception –> If CreateWorkItem –> Create Work Item for non-Shelveset Builds –> Create Work Item

3. Open the Properties for the Create Work Item activity and expand the Custom Fields property.

4. In that, you will see key value pairs and here you have to add for the custom fields which are required in your bug workitem and also change the value for severity field.

5. I tried with these values and everything worked fine. 

 New Dictionary(Of String,String) From {{"System.Reason", "Build Failure"}, {"Microsoft.VSTS.TCM.ReproSteps", "Start the build using TFS Build"}, {"Priority", "1"}, {"Severity", "Critical"}, {"Microsoft.VSTS.CMMI.StepsToReproduce","Start the build using TFS Build"},{"Symptom", "Start the build using TFS Build"},{"Bug.Source","UAT"},{"screen.module", "Performance"}}

 Written by: Deepak Mittal, Support Escalation Engineer

 Reviewed by: George Archer(Senior Escalation Engineer) and Nitish Nagpal(Support Escalation Engineer)