Check-in the Lab default template
authorVásáry Dániel <daniel.vasary@userrendszerhaz.hu>
Tue, 26 Sep 2017 08:08:06 +0000 (08:08 +0000)
committerVásáry Dániel <daniel.vasary@userrendszerhaz.hu>
Tue, 26 Sep 2017 08:08:06 +0000 (08:08 +0000)
git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30467

BuildProcessTemplates/LabDefaultTemplate.xaml [new file with mode: 0644]

diff --git a/BuildProcessTemplates/LabDefaultTemplate.xaml b/BuildProcessTemplates/LabDefaultTemplate.xaml
new file mode 100644 (file)
index 0000000..8ab1825
--- /dev/null
@@ -0,0 +1,173 @@
+<Activity mc:Ignorable="sad" x:Class="TfsBuild.Process" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:this="clr-namespace:TfsBuild;" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mt="clr-namespace:Microsoft.TeamFoundation;assembly=Microsoft.TeamFoundation.Common" xmlns:mtbc="clr-namespace:Microsoft.TeamFoundation.Build.Client;assembly=Microsoft.TeamFoundation.Build.Client" xmlns:mtbco="clr-namespace:Microsoft.TeamFoundation.Build.Common;assembly=Microsoft.TeamFoundation.Build.Common" xmlns:mtbp="clr-namespace:Microsoft.TeamFoundation.Build.ProcessComponents;assembly=Microsoft.TeamFoundation.Build.ProcessComponents" xmlns:mtbw="clr-namespace:Microsoft.TeamFoundation.Build.Workflow;assembly=Microsoft.TeamFoundation.Build.Workflow" xmlns:mtbwa="clr-namespace:Microsoft.TeamFoundation.Build.Workflow.Activities;assembly=Microsoft.TeamFoundation.Build.Workflow" xmlns:mtbws="clr-namespace:Microsoft.TeamFoundation.Build.Workflow.Services;assembly=Microsoft.TeamFoundation.Build.Workflow" xmlns:mtlc="clr-namespace:Microsoft.TeamFoundation.Lab.Client;assembly=Microsoft.TeamFoundation.Lab.Client" xmlns:mtlwa="clr-namespace:Microsoft.TeamFoundation.Lab.Workflow.Activities;assembly=Microsoft.TeamFoundation.Lab.Workflow.Activities" xmlns:mtlwc="clr-namespace:Microsoft.TeamFoundation.Lab.WorkflowIntegration.Client;assembly=Microsoft.TeamFoundation.Lab.WorkflowIntegration.Client" xmlns:mtltc="clr-namespace:Microsoft.TeamFoundation.Lab.TestIntegration.Client;assembly=Microsoft.TeamFoundation.Lab.TestIntegration.Client" xmlns:mttbb="clr-namespace:Microsoft.TeamFoundation.TestImpact.BuildIntegration.BuildActivities;assembly=Microsoft.TeamFoundation.TestImpact.BuildIntegration" xmlns:mtvc="clr-namespace:Microsoft.TeamFoundation.VersionControl.Client;assembly=Microsoft.TeamFoundation.VersionControl.Client" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sad="http://schemas.microsoft.com/netfx/2009/xaml/activities/design" xmlns:sad1="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">\r
+  <x:Members>\r
+    <x:Property Name="Metadata" Type="mtbw:ProcessParameterMetadataCollection" />\r
+    <x:Property Name="LabWorkflowParameters" Type="InArgument(mtlwa:LabWorkflowDetails)" />\r
+    <x:Property Name="Verbosity" Type="InArgument(mtbw:BuildVerbosity)" />\r
+    <x:Property Name="BuildNumberFormat" Type="InArgument(x:String)" />\r
+    <x:Property Name="SupportedReasons" Type="mtbc:BuildReason" />\r
+  </x:Members>\r
+  <this:Process.Metadata>\r
+    <mtbw:ProcessParameterMetadataCollection />\r
+  </this:Process.Metadata>\r
+  <this:Process.LabWorkflowParameters>\r
+    [New Microsoft.TeamFoundation.Lab.Workflow.Activities.LabWorkflowDetails()]\r
+  </this:Process.LabWorkflowParameters>\r
+  <this:Process.Verbosity>[Microsoft.TeamFoundation.Build.Workflow.BuildVerbosity.Normal]</this:Process.Verbosity>\r
+  <this:Process.BuildNumberFormat>["$(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)"]</this:Process.BuildNumberFormat>\r
+  <this:Process.SupportedReasons>Manual, BatchedCI, Schedule, ScheduleForced</this:Process.SupportedReasons>\r
+  <mva:VisualBasic.Settings>Assembly references and imported namespaces serialized as XML namespaces</mva:VisualBasic.Settings>\r
+  <Sequence DisplayName="Application Deployment Workflow" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces">\r
+    <Sequence.Variables>\r
+      <Variable x:TypeArguments="mtbc:IBuildDetail" Name="BuildDetail" />\r
+      <Variable x:TypeArguments="x:String" Name="LabEnvironmentUri" />\r
+      <Variable x:TypeArguments="x:String" Name="BuildLocation" />\r
+      <Variable x:TypeArguments="x:Int64" Name="SnapshotId" />\r
+      <Variable x:TypeArguments="x:Int32" Name="QueueBuildId" />\r
+      <Variable x:TypeArguments="mtbc:BuildStatus" Default="[Microsoft.TeamFoundation.Build.Client.BuildStatus.Succeeded]" Name="BuildStatus" />\r
+      <Variable x:TypeArguments="mtbc:IBuildDetail" Name="ChildBuildDetail" />\r
+      <Variable x:TypeArguments="mtbc:IBuildDetail" Name="SelectedBuildDetail" />\r
+      <Variable x:TypeArguments="x:String" Name="BuildNumber" />\r
+    </Sequence.Variables>\r
+    <mtbwa:UpdateBuildNumber BuildNumberFormat="[BuildNumberFormat]" DisplayName="Update Build Number" />\r
+    <mtbwa:GetBuildDetail DisplayName="Get Build Details" Result="[BuildDetail]" />\r
+    <If Condition="[LabWorkflowParameters.BuildDetails.IsTeamSystemBuild = True AndAlso LabWorkflowParameters.BuildDetails.QueueNewBuild = True]" DisplayName="If Build is needed">\r
+      <If.Then>\r
+        <Sequence DisplayName="Do Build">\r
+          <mtlwa:RunWorkflow BuildDefinition="[LabWorkflowParameters.BuildDetails.BuildDefinitionName]" DisplayName="Start Build Workflow" ProjectName="[BuildDetail.TeamProject]" Result="[QueueBuildId]" />\r
+          <mtlwa:WaitForWorkflow AllowPartiallySucceededBuild="True" BuildDetails="[ChildBuildDetail]" DisplayName="Wait For Build To Complete" MaxWaitTime="[TimeSpan.Zero]" QueueBuildId="[QueueBuildId]" Result="[BuildStatus]" ThrowOnError="True" LabWorkflowType="[Microsoft.TeamFoundation.Lab.Workflow.Activities.WorkflowType.Build]" />\r
+          <Assign DisplayName="Set Build Location">\r
+            <Assign.To>\r
+              <OutArgument x:TypeArguments="x:Uri">[LabWorkflowParameters.BuildDetails.BuildUri]</OutArgument>\r
+            </Assign.To>\r
+            <Assign.Value>\r
+              <InArgument x:TypeArguments="x:Uri">[ChildBuildDetail.Uri]</InArgument>\r
+            </Assign.Value>\r
+          </Assign>\r
+        </Sequence>\r
+      </If.Then>\r
+    </If>\r
+    <mtlwa:WriteDeploymentInformation DeploymentInformationType="[Microsoft.TeamFoundation.Build.Common.DeploymentInformationTypes.Deploy]" Url="{x:Null}" DisplayName="Update Deployment Summary" Message="[String.Format(&quot;Lab environment: {0}&quot;, LabWorkflowParameters.EnvironmentDetails.LabEnvironmentName)]" />\r
+    <mtlwa:GetBuildLocationAndBuildNumber BuildDetails="[LabWorkflowParameters.BuildDetails]" BuildNumber="[BuildNumber]" DisplayName="Get Build Location And Build Number" Result="[BuildLocation]" SelectedBuild="[SelectedBuildDetail]" />\r
+    <If Condition="[LabWorkflowParameters.BuildDetails.IsTeamSystemBuild = True]" DisplayName="Compute build location needed">\r
+      <If.Then>\r
+        <Assign DisplayName="Compute build path">\r
+          <Assign.To>\r
+            <OutArgument x:TypeArguments="x:String">[BuildLocation]</OutArgument>\r
+          </Assign.To>\r
+          <Assign.Value>\r
+            <InArgument x:TypeArguments="x:String">[If(LabWorkflowParameters.BuildDetails.Configuration Is Nothing, BuildLocation, If(LabWorkflowParameters.BuildDetails.Configuration.IsEmpty Or (SelectedBuildDetail.Information.GetNodesByType(Microsoft.TeamFoundation.Build.Common.InformationTypes.ConfigurationSummary, True)).Count = 1, BuildLocation, If(LabWorkflowParameters.BuildDetails.Configuration.IsPlatformEmptyOrAnyCpu, BuildLocation + "\" + LabWorkflowParameters.BuildDetails.Configuration.Configuration, BuildLocation + "\" + LabWorkflowParameters.BuildDetails.Configuration.Platform + "\" + LabWorkflowParameters.BuildDetails.Configuration.Configuration)))]</InArgument>\r
+          </Assign.Value>\r
+        </Assign>\r
+      </If.Then>\r
+    </If>\r
+    <If Condition="[LabWorkflowParameters.EnvironmentDetails.Disposition = Microsoft.TeamFoundation.Lab.Client.LabEnvironmentDisposition.Stored]" DisplayName="If user selected stored environment" >\r
+      <If.Then>\r
+        <Throw DisplayName="Indicate error" Exception="[New System.Exception(&quot;You have selected an environment that is stored in the library. Select an environment that is deployed on a team project host group.&quot;)]"  />\r
+      </If.Then>\r
+    </If>\r
+    <mtlwa:GetLabEnvironmentUri TfsServerUrl="{x:Null}" DisplayName="Get Lab Environment" LabEnvironmentName="[LabWorkflowParameters.EnvironmentDetails.LabEnvironmentName]" ProjectName="[BuildDetail.TeamProject]" Result="[LabEnvironmentUri]" TeamProjectLabLocationName="[LabWorkflowParameters.EnvironmentDetails.HostGroupName]" />\r
+    <If Condition="[LabWorkflowParameters.EnvironmentDetails.RevertToSnapshot = True]" DisplayName=" If Restore Snapshot">\r
+      <If.Then>\r
+        <Sequence DisplayName="Restore Snapshot">\r
+          <mtlwa:GetLabEnvironmentSnapshotId DisplayName="Get Snapshot Details" LabEnvironmentUri="[LabEnvironmentUri]" Result="[SnapshotId]" SnapshotName="[LabWorkflowParameters.EnvironmentDetails.SnapshotName]" />\r
+          <mtlwa:RestoreLabEnvironment DisplayName="Restore Lab Environment to Snapshot" LabEnvironmentUri="[LabEnvironmentUri]" SnapshotId="[SnapshotId]" />\r
+        </Sequence>\r
+      </If.Then>\r
+      <If.Else>\r
+        <mtlwa:WriteDeploymentInformation Url="{x:Null}" DeploymentInformationType="[Microsoft.TeamFoundation.Build.Common.DeploymentInformationTypes.Deploy]" DisplayName="Clean snapshot not specified " sad:VirtualizedContainerService.HintSize="208,209.6" Message="Build definition did not specify a clean snapshot. It is a best practice to use clean snapshot when running the lab workflow." />\r
+      </If.Else>\r
+    </If>\r
+    <If Condition="[LabWorkflowParameters.DeploymentDetails.DeploymentNeeded = True]" DisplayName="If deployment needed">\r
+      <If.Then>\r
+        <Sequence DisplayName="Do deployment">\r
+          <mtlwa:WaitForWorkflowCapabilityServices DisplayName="Wait For Workflow Capability To be Ready" LabEnvironmentUri="[LabEnvironmentUri]" MaxWaitTime="[System.TimeSpan.FromMinutes(20)]" RepairCapabilityBeforeWaitBegins="[LabWorkflowParameters.EnvironmentDetails.RevertToSnapshot = False]" />\r
+          <ForEach x:TypeArguments="x:String" DisplayName="Run Deployment scripts" Values="[LabWorkflowParameters.DeploymentDetails.Scripts]">\r
+            <ActivityAction x:TypeArguments="x:String">\r
+              <ActivityAction.Argument>\r
+                <DelegateInArgument x:TypeArguments="x:String" Name="deploymentConfigurationPair" />\r
+              </ActivityAction.Argument>\r
+              <Sequence DisplayName="Run Script On Lab System">\r
+                <Sequence.Variables>\r
+                  <Variable x:TypeArguments="mtlwa:ScriptDetails" Name="scriptDetails" />\r
+                </Sequence.Variables>\r
+                <mtlwa:InitializeAgentSpecAndEnvironmentVariables BuildLocation="[BuildLocation]" DeploymentScriptDetails="[deploymentConfigurationPair]" DisplayName="Initialize Agent Tags and deployment script" LabEnvironmentUri="[LabEnvironmentUri]" Result="[scriptDetails]" />\r
+                <mtbwa:AgentScope DisplayName="Lab Agent Scope" MaxExecutionTime="[New TimeSpan(0,0,0)]" MaxWaitTime="[New TimeSpan(0, 5, 0)]" ReservationSpec="[scriptDetails.AgentSpec]">\r
+                  <mtlwa:RunDeploymentScript DisplayName="Running Deployment Script" ScriptDetails="[scriptDetails]" ThrowOnError="True" SharedLocationForNetUse="[BuildLocation]" />\r
+                </mtbwa:AgentScope>\r
+              </Sequence>\r
+            </ActivityAction>\r
+          </ForEach>\r
+          <mtlwa:WriteDeploymentInformation DeploymentInformationType="[Microsoft.TeamFoundation.Build.Common.DeploymentInformationTypes.Deploy]" DisplayName="Application Deployment Succeeded" Message="[String.Format(&quot;The application was deployed successfully from the following build location:&quot;)]" Url="[BuildLocation]" />\r
+          <If Condition="[LabWorkflowParameters.DeploymentDetails.TakePostDeploymentSnapshot = True]" DisplayName="Post Deployment Snapshot">\r
+            <If.Then>\r
+              <Sequence DisplayName="Take Post deployment Snapshot ">\r
+                <Sequence.Variables>\r
+                  <Variable x:TypeArguments="x:Int64" Name="PostDeploymentSnapshotChainId" />\r
+                  <Variable x:TypeArguments="x:String" Default="[String.Format(&quot;{0}_{1}&quot;, BuildDetail.BuildDefinition.Name, BuildDetail.BuildNumber)]" Name="PostDeploymentSnapshotName" />\r
+                </Sequence.Variables>\r
+                <If Condition="[String.IsNullOrEmpty(LabWorkflowParameters.DeploymentDetails.PostDeploymentSnapshotName) = False]" DisplayName="Check snapshot name">\r
+                  <If.Then>\r
+                    <Assign>\r
+                      <Assign.To>\r
+                        <OutArgument x:TypeArguments="x:String">[PostDeploymentSnapshotName]</OutArgument>\r
+                      </Assign.To>\r
+                      <Assign.Value>\r
+                        <InArgument x:TypeArguments="x:String">[If(LabWorkflowParameters.BuildDetails.IsTeamSystemBuild = True,String.Format("{0}_{1}_{2}", LabWorkflowParameters.DeploymentDetails.PostDeploymentSnapshotName, BuildNumber,BuildDetail.BuildNumber),String.Format("{0}_{1}", LabWorkflowParameters.DeploymentDetails.PostDeploymentSnapshotName, BuildDetail.BuildNumber))]</InArgument>\r
+                      </Assign.Value>\r
+                    </Assign>\r
+                  </If.Then>\r
+                </If>\r
+                <mtlwa:SnapshotLabEnvironment DisplayName="Taking Post Deployment snapshot" LabEnvironmentUri="[LabEnvironmentUri]" SnapshotChainId="[PostDeploymentSnapshotChainId]" SnapshotName="[PostDeploymentSnapshotName]" />\r
+                <mtlwa:WriteDeploymentInformation Url="{x:Null}" DeploymentInformationType="[Microsoft.TeamFoundation.Build.Common.DeploymentInformationTypes.Deploy]" DisplayName="Taking Snapshot succeeded" sad:VirtualizedContainerService.HintSize="464,22.4" Message="[String.Format(&quot;The following snapshot was taken after the deployment was finished: {0}&quot;, PostDeploymentSnapshotName)]" />\r
+                <mtlwa:WriteDeploymentInformation Url="[PostDeploymentSnapshotChainId.ToString()]" DeploymentInformationType="[Microsoft.TeamFoundation.Build.Common.DeploymentInformationTypes.ConnectToSnapshot]" DisplayName="Added connection link to the Snapshot" Message="[PostDeploymentSnapshotName]" />\r
+              </Sequence>\r
+            </If.Then>\r
+            <If.Else>\r
+              <mtlwa:WriteDeploymentInformation Url="{x:Null}" DeploymentInformationType="[Microsoft.TeamFoundation.Build.Common.DeploymentInformationTypes.Deploy]" DisplayName="Post deployment snapshot not specified" sad:VirtualizedContainerService.HintSize="200,708.8" Message="Build definition did not specify a post deployment snapshot. It is a best practice to take post deployment snapshot when running the lab workflow." />\r
+            </If.Else>\r
+          </If>\r
+        </Sequence>\r
+      </If.Then>\r
+    </If>\r
+    <If Condition="[LabWorkflowParameters.TestParameters.RunTest = True]" DisplayName="Run Tests on Environment">\r
+      <If.Then>\r
+        <Sequence DisplayName="Run Tests">\r
+          <Sequence.Variables>\r
+            <Variable x:TypeArguments="mtltc:TestingCapabilityInformation" Name="TestCapabilityInfo" />\r
+            <Variable x:TypeArguments="x:String" Name="variable1" />\r
+            <Variable x:TypeArguments="mtlwa:TestRunStatistics" Default="[New Microsoft.TeamFoundation.Lab.Workflow.Activities.TestRunStatistics()]" Name="TestResults" />\r
+          </Sequence.Variables>\r
+          <mtlwa:WaitForTestCapabilityServices DisplayName="Wait For Test Capabilities to be ready" LabEnvironmentUri="[LabEnvironmentUri]" MaxWaitTime="[System.TimeSpan.FromMinutes(20)]" RepairCapabilityBeforeWaitBegins="False" />\r
+          <mtlwa:ExecuteRemoteTestRun MaxWaitTime="{x:Null}" BuildNumber="[BuildNumber]" DisplayName="Running Tests" Result="[TestResults]" TestDirectory="[BuildLocation]" LabEnvironmentUri="[LabEnvironmentUri]" TestParameters="[LabWorkflowParameters.TestParameters]" Title="[String.Format(&quot;{0}&quot;, BuildDetail.BuildNumber)]" />\r
+          <If Condition="[TestResults.PassedTests &lt;&gt; TestResults.TotalTests]" DisplayName="If all tests have not passed">\r
+            <If.Then>\r
+              <If Condition="[(LabWorkflowParameters.BuildDetails.IsTeamSystemBuild = True AndAlso LabWorkflowParameters.BuildDetails.QueueNewBuild = True) Or (LabWorkflowParameters.DeploymentDetails.DeploymentNeeded = True)]" DisplayName="Set build status">\r
+                <If.Then>\r
+                  <Assign DisplayName="Partailly succeded">\r
+                    <Assign.To>\r
+                      <OutArgument x:TypeArguments="mtbc:BuildStatus">[BuildStatus]</OutArgument>\r
+                    </Assign.To>\r
+                    <Assign.Value>\r
+                      <InArgument x:TypeArguments="mtbc:BuildStatus">[Microsoft.TeamFoundation.Build.Client.BuildStatus.PartiallySucceeded]</InArgument>\r
+                    </Assign.Value>\r
+                  </Assign>\r
+                </If.Then>\r
+                <If.Else>\r
+                  <Assign DisplayName="Failed">\r
+                    <Assign.To>\r
+                      <OutArgument x:TypeArguments="mtbc:BuildStatus">[BuildStatus]</OutArgument>\r
+                    </Assign.To>\r
+                    <Assign.Value>\r
+                      <InArgument x:TypeArguments="mtbc:BuildStatus">[Microsoft.TeamFoundation.Build.Client.BuildStatus.Failed]</InArgument>\r
+                    </Assign.Value>\r
+                  </Assign>\r
+                </If.Else>\r
+              </If>\r
+            </If.Then>\r
+          </If>\r
+        </Sequence>\r
+      </If.Then>\r
+    </If>\r
+    <mtbwa:SetBuildProperties DisplayName="Set build status" PropertiesToSet="Status" Status="[BuildStatus]" />\r
+  </Sequence>\r
+</Activity>
\ No newline at end of file