The Gated Check-in build in TFS2010

April 18, 2010

Everybody should be already familiar with Continuous Integration or should I say Continuous Building? Automatically building a development codeline after a check-in is often not immediately followed by an integration action towards a main branch. I picked up the term Continuous Building in this article of Martin Fowler.

Apart from the fact how this “build automation” should be called, there are many reasons why you should enforce this behavior on different branch types for your applications. The ultimate goal is to improve the quality of the software application and to reduce the time to release the application in production. By setting up early validation (compilation, automatic testing + other quality gates) through “build automation” you will at least be notified as soon as possible of all kinds of validation errors (= quality check) and you will have a chance to fix them before other team members will be impacted by pulling a get latest on the repository.

Automatically firing a validation build after a check-in will in the end not prevent broken builds and that’s where the Gated Check-in Build will come into play with Team Foundation Server 2010.

The Gated Check-in Build in TFS2010 will prevent broken builds by not automatically committing your pending changes to the repository, but the system will instead create a separate shelveset that will be picked up by the Gated Check-in Build. The build itself will finally decide if the pending changes need to be committed to the repository based on the applied quality gates.

Gated Check-In Build process

The picture above describes the full process of a Gated Check-In build.

How to setup a Gated Check-in build?

The Trigger Tab in the Build Definition window has now an extra option for selecting Gated Check-in.

GatedCheckIn2

At the moment a check-in is attempted by a developer in the branch where the Gated Check-in build is active, the developer will be faced with a dialog box.

GatedCheckIn3

Cancelling this window will not kick off the build, but will also not commit your pending changes to the repository. If you really want to overrule this build with committing your changes directly to the repository, you may select the 2nd checkbox to bypass the validation build (not recommended). By default your pending changes will reside in your local workspace (first checkbox). In the situation where you immediately want to start with new changes – not relying on previous changes – it might be appropriate to uncheck the first option.

In the ideal situation, the build will complete without any validation errors and will eventually commit the changes to the repository. This will also lead to a Gated Check-in notification for the original committer via the Team Build Notification tool.

GatedCheckIn5

GatedCheckIn4

If you had previously chosen to preserve the changes locally (default), you may have noticed that the files you were working on were still checked out during the build … and in fact after a successful build these changes do not reflect the as-is situation anymore of the repository. With the above window you get the option to immediately reconcile your workspace with the up-to-date repository. So, clicking the “Reconcile …” button will give you the opportunity to select the desired files to force an undo in your local workspace and to pickup the changes that were committed by the Gated Check-in build for these files.

Another way to reconcile your workspace (if you for example ignored this window or when the build notification is way too slow) is by right-clicking the completed Gated Check-in Build in the Build Explorer and selecting the option to reconcile your workspace.

GatedCheckIn6  

If you did not choose to preserve the changes locally, there won’t be any changes to reconcile after the Gated Check-in build, even if you forced the reconciliation.

GatedCheckIn8

The Gated Check-in build may also be kicked off manually where you may need to create a shelveset or where you may point to an existing shelveset.

GatedCheckIn9

A last thing to note is that the comment that was originally supplied to the changeset by the developer will be suffixed with the NoCICheckinComment variable (default = ***NO_CI***) to prevent that another continuous integration build will be fired after the final check-in done by the Gated Check-in build.

GatedCheckIn7

Summary

What meant to be a small post on the Gated Check-in feature in Team Foundation Server 2010 ended up in a more detailed explanation of how it works and how you can work with it in the Visual Studio IDE. Remember that you should setup the most appropriate build types according to your specific branches. Not all branches may need a Gated Check-in build. Only configure this for branches that should never have a broken build. A Gated Check-in build may for example validate a big merge operation from a development branch to a stable main branch.


Techdays Belgium 2010 – Session details

April 1, 2010

This year I presented a session at Techdays Belgium on Branching & Merging with Team Foundation Server 2010.

The session slides can be downloaded in the download section of this blog.

A demo on Branching & Merging with TFS2010 was the major part during the presentation and I did practically cover everything I wanted to share with the audience: Branch metadata, Fine-grained security, Branching Visualization, Tracking individual changesets across branches, forward/reverse integration … except for one little important merge action that I forgot to show!

After the creation of my dev branches (from main) I also renamed the solution in those dev branches with an additional suffix to avoid confusion while loading different solutions into Visual Studio 2010. This was done in changeset 121 and I renamed the solution from WebsiteSparkles to WebsiteSparkles_dev1.

DemoTechdays1

Afterwards I did some code changes in the dev branches and pushed some explicit changesets back (Reverse Integration) to the main branch, using the cherry pick option in the merge wizard to avoid merging also the solution rename.

As a result changeset 121 will always remain a merge candidate in the Source Control Merge Wizard.

DemoTechdays2

In some cases you really want to merge changes back to main on the latest version of the development branch without cherry-picking all required changesets. To be able to do that, you need to get rid of changeset 121 as a merge candidate.

This can only be done through the command-line with the tf merge /discard command.

DemoTechdays3

This discard command will make sure that changeset 121 will not be a merge candidate anymore. Note that you still need to commit this action to the repository after executing the command. The discard command will only update your local workspace but won’t do an automatic check-in.

DemoTechdays4

Next time you will run the merge wizard and look for merge candidates, changeset 121 won’t be listed anymore and you may merge from a latest version of this development branch for upcoming changes.

Providing this discard command from within the source control merge wizard would be a very nice addition!


Running Coded UI Tests (from action recordings with MTLM) in Team Builds (TFS2010)

January 21, 2010

With Visual Studio 2010 (Premium/Ultimate) we are able to create several types of automated tests. Automated tests will execute a sequence of test steps and determine whether the tests pass or fail according to expected results.

Coded UI Tests provide functional testing of the user interface and validation of user interface controls.

How to create Coded UI Tests? You could create them directly into Visual Studio, but for this blogpost I want to start from an action recording in Microsoft Test and Lab Manager (MTLM). An action recording is quite useful in manual tests that you need to run multiple times and for recycling common steps in different manual tests that contain shared steps.

I did create a simple test case with different test steps in MTLM to test some behavior on my website.

TestCaseDefinition

From MTLM I started a test run for this test case.

TestSuiteOverview

Before running the test, I do need to check the action recording to be sure to capture my actions for this test.

CreateActionRecording

The Test Runner will give a detailed overview of the recorded actions. Afterwards you will be able to replay all these stored actions in the Test Runner.

ActionRecordings 

After saving the results of this test run (all data is associated to my test case) it’s time to open Visual Studio 2010 and to create a Coded UI Test.

TestCaseAttachments

CodedUITestStart

Instead of choosing the default option to record actions I did choose to use an existing action recording after which I need to retrieve the appropriate test case to link to the associated actions.

ActionRecordingPicker

By clicking OK, Visual Studio will start generating code that will represent my actions that were recorded in Microsoft Test and Lab Manager. On top of that you are also able to add assertions on parts of the user interface in a separate Coded UI Test that you may reuse in other Coded UI Tests.

CodedUITestAssertions

Now, let’s integrate this entire UI test (MyCodedUITest) into the automated build. I created a default new build defintion where I also enabled to run the automated tests.

BuildDefinition

To run unit tests that interact with the desktop during a Team Build, we need to modify the Build Service Host properties in the Team Foundation Administration Console to run the build service as an interactive process instead of running the build service as a Windows Service.

BuildServiceHost

That’s about it. Make sure that the Build Service Host is running in the command line that will pop up after starting the BuildServiceHost. Queue the build and explore the results!

TestResults

Done!

With this post I wanted to highlight the powerful integration of (automated) testing into the upcoming Visual Studio 2010 offering.


New Training offering by Sparkles + Speaking at TechDays Belgium 2010

January 19, 2010

With my new company Sparkles I don’t only provide ALM consultancy services, but I also try to setup advanced training courses in Belgium with local and international experts.

An exclusive partnership with IDesign is set up to bring the best training to Belgium. IDesign’s training courses are among the world’s most intensive, most comprehensive .NET training classes given by the IDesign architects who have a world-renowned reputation as industry leaders. The IDesign architects are all frequent speakers at major international software development conferences, where they present their techniques, ideas, tools and breakthroughs.

In the week of March 1, 2010, Brian Noyes (Chief Architect at IDesign) will be in Belgium (Antwerp) for delivering an intensive 5 day training on Architecting WPF Applications.

On May 3-4, 2010, I will also deliver for the first time a detailed training on the new Application Lifecycle Management features of Visual Studio 2010. The Training class is called ALM with Visual Studio 2010.

This year Microsoft Techdays in Belgium are scheduled on March 30-31 + April 1 and I’m confirmed as a speaker. I will deliver a session on Branching and Merging with Team Foundation Server 2010.

In January I’m also starting to setup Team Foundation Server 2010 (Beta 2) at 2 new clients. More and more small development shops also see the benefits of a fully integrated development platform. Those companies that were still in doubt a few years ago are now convinced because of the promising upcoming release of Visual Studio 2010. The ALM train is on the rails! Very busy, but exciting times!


Application Lifecycle Management with VS2010

December 12, 2009

More than a week ago I did my first training (2 days) on Application Lifecycle Management with Visual Studio 2010. This was the agenda:

  • Introduction to Application Lifecycle Management with Visual Studio 2010
  • Advanced Version Control with Team Foundation Server 2010
  • Testing in Visual Studio 2010
  • Architecture in Visual Studio 2010
  • Applying Scrum with Team Foundation Server 2010

On December 22 I will deliver the Introduction part for a Queaso Get Together in Gent. Feel free to contact me if you want to schedule a session for your company / user group! Always fun to do!

The Introduction slides are also added to the download section.

I also make use of this post to show you the updated VS2010 Stadium Diagram, the new Big Picture (at this moment still without the Teamprise plugin).

So, no sign anymore of Team System editions, the introduction of the Test Elements SKU with Microsoft Test & Lab Manager (MTLM), some new features for TFS2010 (Requirements Management & Test Case Management) and the addition of Lab Management. Excellent offering!


ALM / TFS Books and Documentation

November 12, 2009

This week at TechEd in Berlin, Hans asked for some interesting ALM / TFS books. This is a quick random list of the latest books I know about:

Feel free to add some more books to the list!

Note that there is also a paperback version available of the TFS Guide: Team Development with Visual Studio Team Foundation Server, written by Microsoft Patterns & Practices. The online version can be found at CodePlex: TFS Guide.

If you are looking for the online MSDN documentation, point your favorite browser to the Team Foundation Server Developer Center.

There will also come some new books on VS2010: Professional Visual Studio 2010 Team System: with Team Foundation Server 2010, but I think that the name of the book will still change. Martin Woodward also mentioned that he’s writing on a new Team Build book for VS2010 and I’m sure that there are others under construction. To be continued!


TFS2010: Visualization of merging partial changes in changeset

November 11, 2009

Yesterday (during the Source Code Management session of Brian Harry at TechEd 2009 in Berlin), I noticed for the first time that merging partial changes in a changeset is also clearly visible afterwards. I just found some time between sessions to test it out …

In the screenshot above you may notice that changeset 9 (dev branch) is merged to the main branch. But look at the yellow color of the bar after the merge and the tooltip that is shown when I hover over changeset 11. Changeset 9 consisted of 2 different files that were modified while the merge operation took only 1 modified file in changeset 11. Valuable information!


Feedback VS2010 Beta2?

November 6, 2009

So, you are playing around with VS2010/TFS2010 and you have some remarks, suggestions, bugs, … Please go the Microsoft Connect site for product feedback and bug reporting.

Today I filed a suggestion for the next release of Team Foundation Server: Build Definition History. Unfortunately it’s still not possible to view history of changes made to the Build Defintion: “Drop Location”, “Build Agent”, “Trigger”, … On the Microsoft Connect site, you can easily look up other wanted featured and vote for them … but first vote for my suggestion!

Since a few weeks, there’s also a feedback survey running on Microsoft Visual Studio 2010 and the .NET Framework 4 Beta 2. If you care about the product and want your voice heard, please take some minutes to complete this online survey!


TechEd 2009 in Berlin

October 29, 2009

A few weeks ago I finally decided to sign up for TechEd 2009. This year, with the start of Sparkles I wasn’t planning to attend, but hey: some parties are not to be missed. After all, the VSTS sessions look very promising with top speakers and it’s a week I can spend to focus 100% on the VS2010 Beta 2 release I have installed on my laptop.

My scheduled VSTS agenda for TechEd 2009:

November 9

  • VSTS 2010: A Lap around the Developer and Tester Experience (Brian Harry)

November 10

  • VSTS 2010: A Lap around the New Project Management, Architecture, and Governance Capabilities (Brian Harry)
  • Source Code Management with TFS 2010 (Brian Harry)
  • An Agile Talk on Agility (Peter Provost)
  • Software Testing with VSTS 2010: Part 1, an Introduction (Brian Keller)

November 11

  • Software Testing with VSTS 2010: Part 2, Making It Real (Brian Keller)
  • Tools and Agile Teams (Stephen Forte)
  • Microsoft Visual Studio Team System 2010 Team Foundation Server: Become Productive in 30 Minutes (Brian Keller)
  • How Microsoft Does It: Internal Use of TFS and Microsoft VSTS for Software Development (Stephanie Cuthbertson)

November 12

  • Doing It Right: Planning and Tracking Projects with TFS 2010 (Stephanie Cuthbertson)
  • Successfully Administering and Running TFS 2008/2010 (Neno Loje)
  • Architecture Discovery and Validation with VSTS Architecture Tooling (Peter Provost)
  • You Are Still Using Microsoft Visual SourceSafe? (Neno Loje)

November 13

  • Microsoft Visual Studio Team System “Unplugged” (Stephanie Cuthbertson)

Out-of-the-box source server indexing with TFS2010

October 27, 2009

Wow! This is great! Tonight I just wanted to find out if and how it would work …

This is what I did with Beta 2 of Visual Studio 2010 Ultimate and TFS 2010 Basic on my Win7 laptop:

  • created a new Team Project
  • added a new solution with a C# Library Project to the Team Project
  • added a default Team Build to build the C# Library Project
  • added a new solution with a C# WPF Project to the Team Project
  • referenced the library assembly (file reference to dll) into the C# WPF Project and called a method on a class in that assembly
  • set a breakpoint on that line and hit F5 to start/debug the WPF application
  • pressed F11 (Step Into) when breakpoint was hit

Guess what?! Yes, Visual Studio 2010 was immediately stepping into the source file of the C# Library Project! Sweet!

I remember that it took me some time to get this working for TFS2008!

When you create a new Build Definition with TFS2010, the Index Sources option is set to true by default and this will make sure that source indexing is part of the build.

I took a peek into the DefaultTemplate.xaml file in the BuildProcessTemplates folder and found out that the Index Sources and Publish activity is indeed completely baked in! I love it already!