When we queue a build in TFS, if it failed, TFSBuild will create a bug workitem. If it successes, TFSBuild will update associated workitems.
1 How TFSBuild gets associated changesets
private void AnalyzeChangesets(Item[] lastItems, Item[] currentItems);Declaring Type:
Microsoft.TeamFoundation.Build.Tasks.GenCheckinNotesUpdateWorkItemsAssembly:
Microsoft.TeamFoundation.Build.Tasks.VersionControl, Version=9.0.0.0
The task GenCheckinNotesUpdateWorkItems will get lastItems[] in LastGoodBuildLabel and currentItems[] in CurrentLabel.
A If lastItems[i]’s ItemID matches a item in currentItems, like currentItems[j]
Get all changesets between lastItems[i]’s changesetID and currentItems[j]’s changesetID that include this item.
Notice, not all changeset between them include this item
B If lastItems[i]’s ItemID does not match any item in currentItems and does not exist in Latest version
This means that the Item may be deleted in a changeset.Get all changesets between lastItems[i]’s changesetID and VersionSpec.Latest that include this item.
C If currentItems[i]’s ItemID does not match any item in lastItems
Get all changesets between ChangesetVersionSpec(1) and currentItems[i]’s changesetID that include this item.
2 How TFSBuild get associated WorkItems
Each changesets contains a prroperty WorkItems. In the step1 we can get all associated changesets, and then we can get all WorkItems.
3 How associate a WorkItem to changeset
A In Team Explorer, when you check-in a changeset, you can associate workitems to it.
B in Team Explorer, you can edit a changeset and associate workitems to it.
4 How TFSBuild Update WorkItems
TFSBuild will set item["Microsoft.VSTS.Build.IntegrationBuild"] = this.BuildNumber for all associated workitem which have this field.