1
votes

Is there any way to either manually remove associated changesets and work items from completed build on Team Foundation Server?

For example: I check-in a changeset, but I make a mistake and I link it with wrong work item. Before I notice that, I create a release build which associates changesets and work items and automatically generates changelog. Now the wrong work item is associated with a build. To fix my mistake, I remove link between work item and changeset. However, there is still link between my completed build and work item. Is there any way to remove the link via user interface or I have to dig down into the TFS API?

I tried to delete my completed build and start a new one, however the work items and changesets that were associated with the deleted build are not associated with new build (even if I deleted the previous build). Does anyone know how to force TFS to associate work items and changesets with the new build?

1

1 Answers

2
votes

After doing some research I have stumbled upon this article (https://social.msdn.microsoft.com/Forums/en-US/76462cd5-070f-4fba-8206-550b5511ae68) where someone had similar problem. I have also checked the referenced article on http://www.woodwardweb.com/tfs_top_tip/tfs_top_tip_15.html.

After I deleted the last build, I have also checked the dignostic output from my build and found this line in the log:

Warning: Cannot find the last label 'XXXXXXXXXXXXXXXXXXXX': no changesets will be associated with the build.

And the name of the label that could not be found was exactly the name of the label, created by the deleted build. TFS obviusly remembers the previous label somewhere.

I have checked the TFS collection database and voila, here is the solution:

  1. Delete last few builds (and check the labels for those builds are deleted).
  2. Connect to TFS collection database.
  3. Open table tbl_BuildDefinition
  4. Find the build definition for which you want to reassociate changesets and change values in LastBuildUri, LastGoodBuildUri and LastGoodBuildLabel where:
    • LastGoodBuildLabel is the actual label which will be the new baseline for associating changesets and work items with build,
    • LastGoodBuildUri is the ID of build that created the last label you have in your source history (you can find this in your build history)
    • LastBuildUri is the ID of last run build (same as LastGoodBuildUri)
  5. Run the build. The work items and changesets that were associated with the deleted builds will be re-associated with the new build.