Trigger a CI build after a gated checkin

We want to trigger a CI build after a gated checkin because we have two builds in our company. One with a gated checkin for fast building and very important test. The other build is for code analysis and long running tests. Because we don’t want to wait very long on our CI build we have created that QM build. The problem is that the QM isn’t triggered anymore after changing the CI build to a Gated checkin build.

I found a blogpost for TFS 2010. Because TFS 2013 is slightly different, I thought I would give it an update.

This is how to fix it for TFS 2013

  1. Create an argument called “NoCIOption” of the type boolean with default True.
    CreateDisableCiArgument
  2. Set the metadata information so you understand the argument in your build definition.
    MetadataDisableCiBuild
  3. Use the argument in the TFS 2013 build template. You can find the property under “Run on agent” and then “Get sources from Team Foundation Version Control”. Go to the properties window and change the hard coded “True” in the NoCIOption property to the argument you just created.
    SetDisableCiArgument

Now checkin your changes of the teamplate and use (if you don’t already have) the template in your CI build (the one with the gated checkin). Change the new argument to “false”.

Now your second build (our QM) is also triggered again.

6 thoughts on “Trigger a CI build after a gated checkin

  1. Hello,

    I get below error on following the steps mentioned above. Could you please help me with the same ?
    ————-

    TF215097: An error occurred while initializing a build for build definition :
    Exception Message: Cannot set unknown member ‘Microsoft.TeamFoundation.Build.Activities.TeamFoundation.TfGetSources.NoCIOption’. (type XamlObjectWriterException)
    Exception Stack Trace: at System.Xaml.XamlObjectWriter.WriteStartMember(XamlMember property)
    at System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter)
    at System.Activities.XamlIntegration.FuncFactory1.Evaluate()
    at System.Activities.DynamicActivity.OnInternalCacheMetadata(Boolean createEmptyBindings)
    at System.Activities.Activity.InternalCacheMetadata(Boolean createEmptyBindings, IList
    1& validationErrors)
    at System.Activities.ActivityUtilities.ProcessActivity(ChildActivity childActivity, ChildActivity& nextActivity, Stack1& activitiesRemaining, ActivityCallStack parentChain, IList1& validationErrors, ProcessActivityTreeOptions options, ProcessActivityCallback callback)
    at System.Activities.ActivityUtilities.ProcessActivityTreeCore(ChildActivity currentActivity, ActivityCallStack parentChain, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList1& validationErrors)
    at System.Activities.ActivityUtilities.CacheRootMetadata(Activity activity, LocationReferenceEnvironment hostEnvironment, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList
    1& validationErrors)
    at System.Activities.Validation.ActivityValidationServices.InternalActivityValidationServices.InternalValidate()
    at Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers.ValidateWorkflow(Activity activity, ValidationSettings validationSettings)
    at Microsoft.TeamFoundation.Build.Hosting.BuildProcessCache.LoadFromXaml(String workflowXaml, TextExpressionImports textExpressionImports)
    at Microsoft.TeamFoundation.Build.Hosting.BuildControllerWorkflowManager.PrepareRequestForBuild(WorkflowManagerActivity activity, IBuildDetail build, WorkflowRequest request, IDictionary`2 dataContext)
    at Microsoft.TeamFoundation.Build.Hosting.BuildWorkflowManager.TryStartWorkflow(WorkflowRequest request, WorkflowManagerActivity activity, BuildWorkflowInstance& workflowInstance, Exception& error, Boolean& syncLockTaken)

  2. Hi Sumeet. When the NoCIOption-property can not be resolved, it probably has something to do with the related assembly not being loaded properly. I just looked at my build-template and perhaps you should check yours if it adheres to t his as well:

    – Within the AgentScope, there is a TfGetSources tag with the new NOCIOption attribute. Mine looks like this:

    – As you can see from the snippet above, it is referencing the mtbat namespace, which should be defined in the template as well. In my case, this is how it is referenced:

    xmlns:mtbat=”clr-namespace:Microsoft.TeamFoundation.Build.Activities.TeamFoundation;assembly=Microsoft.TeamFoundation.Build.Activities”

    – The assembly mentioned (Microsoft.TeamFoundation.Build.Activities.dll) should be for version 12.0.0.0 and has to be referenced in your Templates-project. Also, that specific assembly must be available in your CustomAssemblies folder that you specify on your build-controller. Are you sure you have added it? See the following illustration for defining custom-assembly path on your controller(s). http://www.software-architects.com/media/9c5398af-5ec0-418b-af21-471e7a11d4d7/FaBz7Q/time_cockpit/blog/2013/06/tfservice-version-control-path.png

    1. I am not able to paste XAML-snippets but I tried to add the following XAML-snippet in my previous post:

      mtbat:TfGetSources CleanWorkspace=”[CleanWorkspace]” CreateLabel=”[CreateLabel]” DisplayName=”Get sources from Team Foundation Version Control” Enabled=”True” sap2010:WorkflowViewState.IdRef=”TfGetSources_1″ NoCIOption=”[NoCIOption]” VersionOverride=”[GetVersion]”

Leave a Reply