01 January 2008

Reset Association between Changesets and Builds

I was catching up on some MSDN Build Automation forum posts recently and came across a very interesting question by Wayne Sepega.  I have run across the same problem a couple of times in the past and haven't had a good answer until now.

Here is a scenario that we are facing with the TFS Build and the way change sets are associated with builds.

Each build generates an MSI and the MSI is moved from environment to environment.

     1) We get a request to do some work

     2) The work is completed and changes are checked into TFS, as a result of the work over a few days there are 5 change sets.

     3) A build (build 1) is done, and deployed to QA, the 5 changes are associated with Build 1

     4) QA finds a bug in Build 1

     5) Bug is fixed which results in 2 change sets

     6) A Build (build 2) is completed and deployed to QA

     7) Build 2 passes QA and is then promoted to Production and deployed.

In the above scenario there are actually 7 change sets that need to be noted in the deployment to production. However, the final build, Build 2, only has the last two change sets associated with it.
Is there a built in way in TFS to have all outstanding change sets associate with a build once the build quality is promoted? Is there a built in way to get a list of change sets for a build type based on the build quality?

Basically I need to find a way to know about ALL 7 change sets with the final build, without having to do a separate build script for each environment as we want to deploy exactly what QA tests and not rebuild.

Thanks

Wayne

This is a fairly common scenario for an organization that uses a Binary Promotion process to move their application through environments. 

Binary Promotion is a methodology in which a build occurs and the resulting binary code is packaged together (zip, msi, etc) and stamped with a unique name usually containing a version or build number.  This package is then given to QA to deploy to their environment and test.  If anything is found to be wrong with the application, the entire package is thrown out and another version (hopefully with a fix) is built, packaged and promoted to QA.  Once the app passes QA, it is promoted to Production by sending the exact package that was tested in QA to the IT group for installation on the Production Servers, thus "promoting" the binary package through the enviromnents.

Aaron Hallberg responded that the "good build" flag is responsible for associating changesets with a build.  This means that a changeset only gets associated with a build if that build completes successfully.  The good build flag is implemented by a bit field aptly named GoodBuildFlag located in the Builds table of the TFSBuild database.  To get access to this flag, you call the BuildStore.UpdateFlags method.  Passing false to the UpdateFlags method will reset the GoodBuildFlag and reset the association. 

4 comments:

Dan Sniderman said...

This is great information - exactly what I need for the implementation I'm working on!

Steven St Jean said...

I'm actually planning on writing a little test app that retrieves the builds and allows the user to remove the changeset associations. Hopefully I'll have some down time to play with it.

- Steve

Lone VVolf said...

I am trying to implement a task to do this automatically, based on previous builds' Build Quality field. Strangely, though, I can't find how to set this flag in the TFS 2008 API. It seems it's just been removed! Any idea how we can set this programmatically in the new API?

Anonymous said...

This still doesn't really answer or solve the scenario. Can this flag be reset or the associations changed automatically through setting build quality or using TFS tools? In other words, can I do it without writing my own tool to do it?

Post a Comment