LabDefaultTemplate workflow activities
This topic describes the Windows Workflow activities in the LabDefaultTemplate.11.xaml file. LabDefaultTemplate defines the Lab Management workflow process that enables you build, deploy, and test your application in a lab environment. To learn more about Windows Workflow, see this page A Developer's Introduction to Windows Workflow Foundation (WF) in .NET 4 on the MSDN website.
Requirements
- Visual Studio Ultimate, Visual Studio Premium, Visual Studio Test Professional
Initializing the Workflow
The root of the LabDefaultTemplate is the TfsBuild.Process activity. This ActivityBuilder initializes the global arguments for the workflow build definition from the input supplied in the Build Definition window and in the Lab Workflow Parameters wizard.
Arguments
The LabWorkflowParameters argument contains the data that is supplied in the Lab Workflow Parameters wizard. This argument is a LabWorkflowDetails object that contains the following objects:
BuildDetails |
A Microsoft.TeamFoundation.Lab.Workflow.Activities.BuildDetails object that stores the build details for the build, deploy, and test workflow. |
DeploymentDetails |
A Microsoft.TeamFoundation.Lab.Workflow.Activities.DeploymentDetails object that stores the information that is required for the deployment of a build in the workflow. |
EnvironmentDetails |
A Microsoft.TeamFoundation.Lab.Workflow.Activities.LabEnvironmentDetails object that stores the information that identifies the environment to use for a build, deploy, and test scenario. |
TestParameters |
A Microsoft.TeamFoundation.Lab.Workflow.Activities.RunTestDetails object that stores the test parameter details that are required to create the automated test run. |
The following arguments are also declared at the global scope:
Argument |
Type |
---|---|
Metadata |
ProcessParameterMetadataCollection |
Verbosity |
A Verbosity enumerated value that specifies the amount of information that is written to the log. |
BuildNumberFormat |
A String that specifies format of the build number. |
SupportedReasons |
A BuildReasonenumerated value that specifies the reason for the build. |
Application Deployment Workflow Sequence
The Application Deployment Workflow sequence controls the entire build, deploy, and test scenario. Application Deployment Workflow declares the following variables:
|
Running the Build
Update Build Number |
Update Build Number expands and returns the build number in the BuildNumberFormat argument. Update Build Number is a Microsoft.TeamFoundation.Build.Workflow.Activities.UpdateBuildNumber activity. |
Get Build Details |
Get Build Details returns the data that is required to run or access the build that was specified in the Workflow Wizard. The IBuildDetail object is stored in the BuildDetail variable. Get Build Details is a Microsoft.TeamFoundation.Build.Workflow.Activities.GetBuildDetail activity. The template sets the following properties:
|
If Build is needed determines whether a new build is needed for a Team System build process. If the conditions are met, the workflow runs the Do Build sequence. |
|
The Do Build sequence initiates the build, waits for the build to complete, and then sets the build location. |
|
Start Build Workflow |
Start Build Workflow queues a new build on the specified build controller and returns the id of the queued build in the QueueBuildId variable. Start Build Workflow is a RunWorkflow activity. The template sets the following properties:
|
Wait For Build To Complete |
Wait For Build To Complete suspends execution until the build is complete or a timeout interval is elapsed. The activity throws an exception if the timeout is reached. The activity returns the status of the build in the BuildStatus variable, and data about the new build in the ChildBuildDetail variable. Wait For Build To Complete is a WaitForWorkflow activity. The template sets the following property values:
|
Set Build Location |
Set Build Location assigns the location of the build from the ChildBuildDetail variable to the BuildDetails.BuildUri property of the LabWorkflowParameters argument. |
Deploying the Application
Update Deployment Summary |
Update Deployment Summary writes the name of the deployment target environment to the build page. Update Deployment Summary is a WriteDeploymentInformation activity. |
GetBuildLocationAndBuildNumber |
GetBuildLocationAndBuildNumber returns the drop location for the build to BuildLocation variable. GetBuildLocationAndBuildNumber is a GetBuildLocationAndBuildNumber activity. The template sets the following properties:
|
If the Compute build location needed conditions are met, Compute build path adds platform and build configuration subfolders to the drop location. |
|
If user selected stored environment checks that the environment is deployed, and Indicate error throws an exception if the environment is stored in the library. |
|
Get Lab Environment |
Get Lab Environment returns the uri of the environment to the LabEnvironmentUri variable. Get Lab Environment is a GetLabEnvironmentUri activity. The template sets the following properities:
|
If Restore Snapshot determines whether the user requested that the environment be restored to a clean snapshot. If the condition is met, the Restore Snapshot sequence is run; otherwise Clean snapshot not specified writes a warning message to the build summary. |
|
In the Restore Snapshot sequence, Get Snapshot Details calculates the id of the snapshot, and Restore Lab Environment to Snapshot performs the restoration. |
|
Get Snapshot Details |
Get Snapshot Details is a GetLabEnvironmentSnapshotId activity. The template sets the following properties:
|
Restore Lab Environment to Snapshot |
Restore Lab Environment to Snapshot is a RestoreLabEnvironment activity. The template sets the following properties:
|
If deployment needed determines whether the user has requested a deployment. |
|
If the condition is met, the Do deployment sequence is run. |
|
Wait For Workflow Capability To be Ready |
Wait For Workflow Capability To be Ready suspends execution until the workflow capability of the environment is ready or a timeout interval is reached. If the timeout interval is exceeded an exception is thrown. Wait For Workflow Capability To be Ready is a WaitForWorkflowCapabilityServices activity. The template sets the following properties:
|
Run Deployment scripts executes the Run Script On Lab System sequence on each deployment script that is contained in the DeploymentDetails.Scripts property list of the LabWorkflowParameters argument. |
|
The Run Scripts on Lab System sequence executes the specified script on a virtual machine in the environment. Run Scripts on Lab System declares the following variables:
|
|
Initialize Agent Tags and deployment script |
Initialize Agent Tags and deployment script expands the macros and tags of the script and returns the results in a ScriptDetails object. Initialize Agent Tags and deployment script is a InitializeAgentSpecAndEnvironmentVariables activity. The template sets the following values:
|
Lab Agent Scope |
Lab Agent Scope determines whether the lab agent is installed and running on the target virtual machine and then calls Running Deployment Script to execute the script. An exception is thrown if any of the scripts fail on a machine. Lab Agent Scope is a Microsoft.TeamFoundation.Build.Workflow.Activities.AgentScopeactivity. The template sets the following properties:
|
Running Deployment Script |
Running Deployment Script executes the deployment script on the target virtual machine. Running Deployment Script is a RunDeploymentScript activity. The template sets the following values:
|
Application Deployment Succeeded |
Application Deployment Succeeded writes information to the build summary. Application Deployment Succeeded is a WriteDeploymentInformation activity. |
Post Deployment Snapshot determines whether the user has requested that a snapshot of the environment is to be saved after the deployment. If this condition is met, the Take Post Deployment Snapshot sequence is executed. Otherwise, Post deployment snapshot not specified writes a warning message to the log. |
|
Take Post Deployment Snapshot sequence Take Post Deployment Snapshot declares the following variables: |
|
Check Snapshot Name determines whether a snapshot name has been specified. If the condition is met, the specified name is used; otherwise the default value is used. |
|
Taking Post Deployment snapshot |
Taking Post Deployment snapshot is a SnapshotLabEnvironment activity that creates the snapshot. The template sets the following properties:
|
Taking Snapshot succeeded |
Taking Snapshot succeeded writes the snapshot name to the build summary. Taking Snapshot succeeded is a WriteDeploymentInformation activity. |
Added connection link to the Snapshot |
Added connection link to the Snapshot writes the url of the snapshot to the build summary. Added connection link to the Snapshot is a WriteDeploymentInformation activity. |
Running Tests
Run Tests on Environment determines whether automated tests were requested. If the condition is met, the Run Tests sequence is executed. |
|
Run Tests Run Tests declares the following variables:
|
|
Wait For Test Capabilities to be ready |
Wait For Test Capabilities to be ready suspends execution until the testing capability of the environment is ready or a timeout interval is reached. If the timeout interval is exceeded an exception is thrown. Wait For Test Capabilities to be ready is a WaitForTestCapabilityServices activity. The template sets the following properties:
|
Running Tests |
Running Tests executes the tests and returns the test results. Running Tests is an ExecuteRemoteTestRun activity. The template sets the following values:
|
If all tests have not passed determines whether any tests have failed and executes Set build status if the condition is met. |
|
Set build status |
Set build status determines whether the workflow includes the build or deployment of the application. If this condition is met, Partially succeded sets the workflow status to the BuildStatus.PartiallySucceeded value. Otherwise, Failed sets the BuildStatus variable to Failed. |