June 23, 2014

Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus - Step 1: Customize the TFS workflow

This is the second part of my series of post about how to Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus. If you didn't have read the post about the general architecture you should read it first.

The first step of this tutorial is: "How to customize the Team Foundation Server (TFS) 2013 workflow".
  1. Into the TFS "build" tab of visual studio, right click on the build definition to customize and click on "Edit Build Definition"
  2. In the "Process" tab, click on show details and then download you current template. This will download a xaml file. Save it somewhere in your project and rename the file.
  3. Now you can open this file in visual studio or in a notepad++ for example. I will use both tools depending of what I need to change. Sometime it is easier to edit in notepad, sometime in visual studio.
  4. First thing to do is adding a section with the octopus parameter and another one with the TDS options as in this screenshot:
  5. To do that, wa need to create 5 new variables by adding the following code before </x:Members>
    <x:Property Name="Octopus_OctoPackPublishApiKey" Type="InArgument(x:String)" />
    <x:Property Name="Octopus_OctoPackPublishPackageToHttp" Type="InArgument(x:String)" />
    <x:Property Name="Octopus_RunOctoPack" Type="InArgument(x:Boolean)" />
    <x:Property Name="TDS_IsDesktopBuild" Type="InArgument(x:Boolean)" />
    <x:Property Name="TDS_GeneratePackage" Type="InArgument(x:Boolean)" />
  6. Add those parameter into the UI by adding the following code before </mtbw:ProcessParameterMetadataCollection>
    <mtbw:ProcessParameterMetadata BrowsableWhen="Always" Category="#500 Octopus" Description="Set this to true to run OctoPack" DisplayName="OctoPack : Run OctoPack" ParameterName="Octopus_RunOctoPack" />
    <mtbw:ProcessParameterMetadata BrowsableWhen="Always" Category="#500 Octopus" Description="Url where the octopack need to be published" DisplayName="OctoPack : Publish package to http" ParameterName="Octopus_OctoPackPublishPackageToHttp" />
    <mtbw:ProcessParameterMetadata BrowsableWhen="Always" Category="#500 Octopus" Description="API Key of the nuget server for the publish" DisplayName="OctoPack : API Key of the nuget server" ParameterName="Octopus_OctoPackPublishApiKey" />
    <mtbw:ProcessParameterMetadata BrowsableWhen="Always" Category="#600 TDS" Description="Set this to true if it is a desktop build" DisplayName="TDS : IsDesktopBuild" ParameterName="TDS_IsDesktopBuild" />
    <mtbw:ProcessParameterMetadata BrowsableWhen="Always" Category="#600 TDS" Description="Set this to true to generate the packages" DisplayName="TDS : Generate packages" ParameterName="TDS_GeneratePackage" />
  7. Switch to Visual Studio because it will be easier to edit. Click on the "Run MsBuild" and the in the properties window, replace the "CommandLineArgument" by the following one:
    String.Format("/p:SkipInvalidConfigurations=true {0} /p:OctoPackPublishPackageToHttp={1} /p:OctoPackPublishApiKey={2} /p:RunOctoPack={3} /p:IsDesktopBuild={4} /p:GeneratePackage={5}", AdvancedBuildSettings.GetValue(Of String)("MSBuildArguments", String.Empty), [Octopus_OctoPackPublishPackageToHttp], [Octopus_OctoPackPublishApiKey], [Octopus_RunOctoPack], [TDS_IsDesktopBuild], [TDS_GeneratePackage])
    If you prefer to do that in notepad, don't forget to escape the characters.
    This change will add some extra parameters to the msbuild command.
  8. Check-in this workflow into TFS.
  9. Edit your build definition again. In the "Process" tab, expand the "Build process template" section and click on "New..."
With those steps you should have your TFS template with your custom fields. In the next post I will explain how to use it.

Next steps:
  1. Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus - Architecture
  2. Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus - Step 1: Customize the TFS workflow
  3. Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus - Step 2: Configure TFS
  4. Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus - Step 3: Configure octopus
  5. Setup a continuous integration for Sitecore with TDS - TFS 2013 and Octopus - Step 4: Align the version number

1 comment:

  1. great post!
    I had to change the AdvancedBuildSettings parameter to the default one: MSBuildArguments.
    Otherwise I get a compiler error (not accessible) in vs2013.

    ReplyDelete