As a part of the standard build process, we first get the latest sources from the repository, apply the label, build, get the checkin details between last successful build and current build (change sets) and the work items that were resolved by these checkins.

GenCheckinNotesUpdateWorkitem (GCNUW) task is responsible for getting the checkin details (changesets) between the last successful build and current build and retrieve/update the work items associated with them.

The algorithm for the task is

1.    Check/validate the current label and its scope, last label and its scope.

2.    Retrieve the files and folders detailed, versioned by current label. They form the set of current items

3.    Retrieve the files and folders detailed, versioned by last label. They form the set of last items. If the last label is not specifies (first build), then set the last item as empty (scoped by team project)

4.    Categorize the items into three buckets. Note that we will consider only non deleted items (Item.DeletionId != 0). If the item belong to

a.    last label (item list) and current label (item list), add it to ChangedItembucket

b.    only last label (item list) then add it to DeleteItembucket

c.    only current label (item list) then add it to AddedItembucket

5.    Foreach (item) in (ChangedItembucket, DeleteItembucket, AddedItembucket)

a.    Do VersionControlServer.QueryHistory on item to get the changesets and add them to the Dictionary<int, Changeset> changesets.

b.    Note that we are ignoring the duplicate changesets

6.    Foreach (changeset in Dictionary [populated in step 5])

a.    Get the workitems associated with the changeset

b.    If the UpdateWorkItems flag is set, then update the workitem with build details

7.    Raise the event for each changeset in Dictionary (populated in step 5). The event will be captured by the msbuild logger and the information will be shown in the reports.

Other blogs on same topic by [Khushboo]