Inside TFS

Batched Gated Builds in Visual Studio 2012 TFS

Batched Gated Builds in Visual Studio 2012 TFS improves on the concept of gated builds by allowing you to specify a build definition to build more than one queued build at a time.

The past several columns have demonstrated the automated build process in Team Foundation Server, known as Team Foundation Build. This build service has been available in Team Foundation Server since the initial 2005 release, and has undergone some significant changes in the past seven years. This column introduces one of the new features available in the Visual Studio 2012 release: batched gated builds.

Gated builds have been available since Team Foundation Server 2010. Essentially, a gated build requires that, in order for a developer to check-in their code, the code must run through the build process successfully.

When a developer checks in their code, it's not submitted to the version control repository directly, but instead is submitted as a shelveset. The build server then grabs the latest version of the code from version control, merges in the changes from the submitted shelveset, and executes the build. If the build succeeds, the shelveset is automatically checked into version control. If the build fails, the developer is given the option to unshelve their code and fix it. Gated builds ensure that the build is never broken, because code can never be checked into the repository until it successfully builds.

The main problem with gated builds is time. If a build takes a long time to execute, and you have large teams checking code in frequently, this can lead to long wait times for builds to complete and code to be checked into the repository. Team Foundation Build 2012 provides a solution to this issue by allowing you to specify a build definition to build more than one queued build at a time -- i.e., to batch the gated builds.

On the Build Definition Trigger tab (Figure 1), you can specify to "merge and build" gated builds, by selecting the Gated Check-in option, and then selecting the Merge checkbox. You will also need to specify the maximum number of build requests to be included in each batch. In Figure 1, this value has been set to 3.


[Click on image for larger view.]
Figure 1. Configuring a batched gated build.

When gated builds are batched, the maximum number of check-ins (specified in the build definition, Figure 1), are merged together and executed as one build. Team Foundation Build has been updated to handle multiple queued builds and build failures. The algorithm works like this:

  • A build starts with all the batched build requests. For example, let's say there are three build requests in the batch.
  • If the build succeeds, all three requests are checked into Team Foundation Version Control, and you're finished.
  • If the build fails, all three build requests are returned to the build queue; but this time they will each be built individually.
  • Each build request will execute individually, allowing the build process to isolate which request(s) caused the earlier build failure
  • Those requests that succeed in building will be checked in, while those that fail will be rejected.

A potential drawback to this method is that if a batched build fails, you'll end up building the application more times than you would have if you didn't batch at all. Therefore, you should strive to keep the batch size to a small, manageable number, such as five or less. Figure 2 shows the results of a batched gated build.


[Click on image for larger view.]
Figure 2. Results of a batched gated build.

You can see that a batched build ran, and failed, so all the check-ins were initially rejected. Then each request was run individually. Two of them failed, but one of them passed. If you open the passing build, there is a Request Summary section, listing the build request that triggered this build. If you click the build request in this section, it will open a new view, called the Build Request View, shown in Figure 3.


[Click on image for larger view.]
Figure 3. The Build Request view.
This view looks very similar to the Build Details view, but contains information specifically about a build request. In looking at Figure 3, you can see this build request was initially built as part of a batch, but failed. When it ran again the second time, it succeeded, and the check-in was committed to the repository.

Gated builds ensure that the code stored in Team Foundation Version Control will always compile. Batched gated builds enhance this functionality even more, by providing a solution to the problem of large queues and long wait times normally associated with gated builds.

About the Author

Mickey Gousset spends his days as a principal consultant for Infront Consulting Group. Gousset is lead author of "Professional Application Lifecycle Management with Visual Studio 2012" (Wrox, 2012) and frequents the speaker circuit singing the praises of ALM and DevOps. He also blogs at ALM Rocks!. Gousset is one of the original Team System/ALM MVPs and has held the award since 2005.

comments powered by Disqus

Featured

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

  • VS Code Copilot Previews New GPT-4o AI Code Completion Model

    The 4o upgrade includes additional training on more than 275,000 high-quality public repositories in over 30 popular programming languages, said Microsoft-owned GitHub, which created the original "AI pair programmer" years ago.

  • Microsoft's Rust Embrace Continues with Azure SDK Beta

    "Rust's strong type system and ownership model help prevent common programming errors such as null pointer dereferencing and buffer overflows, leading to more secure and stable code."

  • Xcode IDE from Microsoft Archrival Apple Gets Copilot AI

    Just after expanding the reach of its Copilot AI coding assistant to the open-source Eclipse IDE, Microsoft showcased how it's going even further, providing details about a preview version for the Xcode IDE from archrival Apple.

Subscribe on YouTube

Upcoming Training Events