1

Target Environment: TFS 2015 Update 3

We are attempting to get the vNext build system to allow us to to only associate Changesets and Work Items to a build once it is deployed via Release Management. However, the TFS vNext build system automatically associates these items to builds at build time (based on the last successful build). The old XAML build system had a property to turn this off called SkipGetChangesetsAndUpdateWorkItems, but it no longer exists in the new system.

Therefore, I need to add a task/script at the end of the vNext build process to remove these associations (and then add a similar task to Release Management to re-associate them). It's not the simplest task in the world, but it seems like something should be feasible via the TFS REST API.

However, I cannot for the life of me find out how these associations are formed. The JSON for the Changesets don't seem to mention an associated build, and the JSON for the build doesn't seem to mention a list of associated changesets.

How are these associations between Changesets/Work Items and builds defined?

mattbbpl
  • 87
  • 1
  • 7

1 Answers1

1

There is no such Rest API can achieve this of remove changeset. In XAML build, the related info are stored in a SQL table called dto.tbl_BuildDefinition, for which you want to reassociate changesets and change values in LastBuildUri, LastGoodBuildUri and LastGoodBuildLabel . Details please refer this link: Re-associate changesets and work items with build For vNext build definition, I didn't find something similar in SQL. However there must be some somewhere stored the association.

For the association between workitem and build, there is a method called $WorkItemAssociatedURL such as

$WorkItemAssociatedURL = $collectionURL + $project + “/_apis/build/builds/” + $BuildId + “/workitems?api-version=2.0”

$ResponseJSON = Invoke-RestMethod -Uri $WorkItemAssociatedURL -ContentType “application/json” -headers $headers -Method GET

For more detail info you can refer this blog: Build association with work Items in vNext

Community
  • 1
  • 1
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • Thanks for your input. I'm currently investigating your links and seeing what I can do with the information contained therein. – mattbbpl Nov 17 '16 at 21:36
  • 1
    Holy cow, I don't think this is entirely possible. I can definitely add work items to builds using what you posted, but those links are not the same ones the build system associates automatically. And I can't seem to remove those, although they otherwise seem to behave similarly. Changesets can't seem to be removed either. Your response gets me the closest I've seen so far. Perhaps Microsoft will fully allow this someday in the near future. – mattbbpl Nov 17 '16 at 22:24
  • 1
    I just spoke with Microsoft, and the 2017 on-premises version of TFS has the ability to choose which releases to diff (For example, if you have Build # 40 that was successfully deployed to Prod, then 9 more builds that never made it through testing and Build #50 that made it to Prod again, you can generate a list of work items and changesets between any of those builds [including #50 and #40] you want thus making my original request irrelevant). Pro: My complicated request is no longer needed Con: We have to upgrade to 2017 to make use of it – mattbbpl Dec 08 '16 at 22:31
  • @mattbbpl Thanks for the kindly sharing. – PatrickLu-MSFT Dec 09 '16 at 01:35