kev.Blog()

June 30, 2009

Synchronising Comments Between TFS and QC

Filed under: Juvander — kevinhick @ 12:05 pm

There’s been a couple of questions on the Juvander forums about how to sync comments from the TFS History fieldinto Quality Center.

Unfortunately the TFS Bug Item Synchroniser doesn’t have this feature yet, but there is a way to do it.

Step 1

Create a new ‘QC Comments’ html field in your TFS work item. In my solution this is a read only field on the work item form and is updated from the Comments in the Work Item History field only.

Step 2

Configure the Synchroniser to sync the QC Comments field with the new custom TFS field.

I’ve checked the ‘HTML Formatted Field’ option from QC to TFS but not vice versa and configured an invalid character filter value map for the QC to TFS sync (I also use this on Title and Description)

<ValueMap Name="FilterInvalidChars">
<Value MatchTypeValue="RegularExpressionMatch" ReplaceString=" " PatternString="[^\t\r\n\u0020-\uFFFD]" MatchPatternString="[^\t\r\n\u0020-\uFFFD]" />
</ValueMap>        

Step 3

Create a Web Service that subscribes to the WorkItemChangedEvent from TFS

The History field (which if changed will be in the TextFields array) will be populated with any additions, so test the work item change event for an addition and append the comments to the custom ‘QC Comments’ field, marking with ChangedBy for more info. In my solution I also remove the changed field xml by removing everything between ‘<div‘ and ‘div>‘ and exclude ‘Associated with Changeset’ comments.

Now when comments are made in TFS, the web service updates the ‘QC Comments’ field and the Synchroniser updates QC from that. When QC comments are updated the Synchroniser just does a straight update to the ‘QC Comments’ field.

December 18, 2008

Invalid Characters Cause TFS to QC Sync Error

Filed under: Juvander — kevinhick @ 3:18 pm

I was creating a new synchronised work item in TFS and pasted some text from an email into the Description. It looked fine and the work item synchronised to a QC defect (using the Juvander tool I’ve mentioned before). However, when the QC defect synchronised back to TFS it failed with this validation error in the log file:

Field ‘Description’ is invalid (invalid characters (valid characters are: 0x09 | 0x0A | 0x0D | [0x20-0xFFFD]))

I looked more closely at the QC defect and saw something like this:

I pasted this in from an email

It was then that I realised that the rich text in QC couldn’t cope with ‘Accented quotes’ and non-printable characters had been substituted instead.

Thanks to the nifty new regular expression value map Ilpo put in the sync tool for me, I was able to stop this error by adding the following value map to QC text fields:

<ValueMap Name="FilterInvalidChars">

<Value MatchTypeValue="RegularExpressionMatch" ReplaceString=" " PatternString="[^\t\r\n\u0020-\uFFFD]" MatchPatternString="[^\t\r\n\u0020-\uFFFD]" />

</ValueMap>

This removes the non-printable characters from the QC field before sending it to TFS and obviously causes a loss of fidelity but it’s better than the alternative – a failure to sync!

Note: If you’re going to use this feature, make sure you get Patch 1 of Version 1.6 from Juvander, otherwise you’ll get NullReferenceException if there is no value in the text field.

May 28, 2008

FileAttachmentException

Filed under: Juvander — kevinhick @ 10:18 am
I’m using Juvander Consultings TFS Bug Item Synchronizer.
 
When attaching a file to a Test Director defect, the transfer failed.  I found the following error in the log.
 
Microsoft.TeamFoundation.WorkItemTracking.Client.FileAttachmentException: Attachment upload failed. Check that you have a network connection and that the Team Foundation Server is available. If the problem persists, contact your Team Foundation Server administrator. —> System.Exception: HTTP Status Code : Forbidden – TF51311: Cannot upload the file because the user does not have permissions to upload files to work items.
 
I tracked the problem to a permission on the Area Path.  The service account used for sync needs ‘Edit Work Items in this node’.

Create a free website or blog at WordPress.com.