How to have CI builds run after a Gated Build.

Problem:

My new TFS2010 CI builds are not running after my Gated Builds.

Solution:

Customize the DefaultTemplate.xaml file to allow you to pass in the value to use for the NoCIOption property of the SyncWorkspace activity.

Code:

N/A

Explanation:

By default the new Gated Check In feature of TFS2010 prevents your CI builds from running.  I configure my Gated Builds to be very quick and many do not run unit test.  My goal with my Gated Builds is to make sure the code will compile.  My CI builds are in place to make sure the code is not broken by running unit test.  So after a successful Gated build I want my longer running CI build to run as well.  To achieve this I customized the DefaultTemplate.xaml file to allow me to set the NoCIOption property when I create a new build definition.

To begin open the DefaultTemplate.xaml file in VS2010 and click the Arguments button at the bottom of the workflow designer to show the workflow arguments.  Add a Boolean argument named “DisableCI” and set the Default value to True.  This will allow the template to continue to work as it was designed.

Now let’s add a nice coat of polish on our argument.  Click the ellipses next to the default value of the Metadata argument to show the “Process Parameter Metadata Editor window”.  Click the Add button and enter in the following information and click OK.

Parameter Name – DisableCI
Display Name – Disable CI
Category – Advanced
Description – When set to true will disable CI builds from running after a Gated Build.
View this parameter when – Always show the parameter

Now let’s modify the activity to use the value of the argument.  Navigate to the Activity labeled “Get Workspace”.  It can be located under “Process > Overall Build Process > Run On Agent > Initialize Workspace > Get Workspace”.  Right click the “Get Workspace” activity and select Properties from the context menu.  Change the NoCIOption property from True to DisableCI. 

To complete the customization simply save the file and check in the file into TFS.   Now when you create/edit a build definition you will see a new “Disable CI” property you can set for the build definition.  Because we selected “Always show the parameter” we will also see this property when you queue a new build as well. Simply set it to False to have your CI builds run after your Gated Builds.

 

Add comment

Loading