Create a Step Group Template
A step group in Harness is a collection of deployment steps that are executed together as a single unit. This allows you to organize and manage complex deployment processes by dividing them into smaller, manageable steps. A step group can contain any type of pipeline step, including script steps, artifact deployment steps, and infrastructure deployment steps. You can also control the order in which the steps in a step group are executed. In addition, you can specify conditions for skipping certain steps based on the outcome of previous steps. Overall, step groups are a useful tool for streamlining and organizing your deployment processes in Harness.
By creating a step group template, you can standardize and simplify your deployment processes, and reduce the time and effort required to create new pipelines and templates. When using in a deployment, you can customize certain aspects of the template. Additionally, you can apply conditions to the steps in a step group template to make it more flexible and reusable in different deployment scenarios.
You can create a step group template at the project, organization, and account levels.
Product Demo Vide
Create a step group template
Let us start by creating a template in the project scope within the Deployments module. You can do this in any project.
Navigate to the Deployments module and in Projects select the desired project.
Under Project Setup, select Templates.
Select New Template.
Select Step Group to create a stage template.
The Create New Step Group Template settings appear.
In Name, enter a name for the template.
In Version Label, enter the version of the stage. For example, v1.
In Save To, select the scope at which you want save the template.
To set up your template, select one of the following:
- Inline: Save the template in Harness.
- Remote: Save the template in a Git repository.
Create a remote template
In Git Connector, select or create a Git Connector to the repo for your project. For more information, go to Code Repo Connectors.
In Repository, select your repository.note
If your repository is not listed, enter the repository name to search and select it. Create the repository in Git before entering it in Select Repository. Harness does not create the repository for you.
In Git Branch, select your branch.note
If your branch is not listed, enter the branch name to search and select it. Create the branch in your repository before entering it in Git Branch. Harness does not create the branch for you
Harness auto-populates the YAML Path. You can change this path and the file name.
Select the stage type
Select Deploy. The deploy stage type is a CD Stage that enables you to deploy any service to your target environment.
This topic uses the Deploy stage type. You can select a different stage type.
The stage type you select determines where you can reference the step group template in the pipeline. If you select Deploy as the stage type, you can reference the template in any pipeline's deploy stage. If you select Build as the stage type, you can reference the template in any pipeline's build stage.
In your stage, select Add Step and then select Add Step.
Select a step type from the step library.
Let us add a Canary Deployment step.
Enter a name for the step and then select Apply Changes.
Next, let us add an approval step.
Select Add Step and then select Add Step.
In Approval, select Harness Approval.
Enter a name for the step. Select the user groups and then select Apply Changes.
You can add more steps to form a step group.
You can also create step group templates using the Harness API or Harness Terraform Provider.
Harness detects the step group object and automatically creates the step group template based on the YAML body. You need not define any additional fields in the API or Terraform provider.
For more information on creating templates using API, see Create Templates API.
For more information on creating templates using Terraform Provider, see Platform Template.
Here is an example of a step group template YAML.
name: Validate Kubernetes Rollout
name: Output Servie Manifest
name: Approve Harness Manifests
approvalMessage: Please review the following information and approve the pipeline progression
name: Rolling Deployment
- Click Save to save the step group template you just created.
Add details for conditional execution
A step group can have its own Conditional Execution settings. This is in addition to the Conditional Execution settings at the Stage level. The Conditional Execution settings of the step group apply to all of its steps.
For more information, see Step Skip Condition Settings.
The Conditional Execution settings of any step in a step group overrides the conditional execution settings of the step group.
If you do not use step group Conditional Execution settings, then the stage's conditional execution settings are applied.
Add a failure strategy
A step group can have its own Failure Strategy separate from the failure strategy for the stage.
The failure strategy can execute the rollback steps for the step group.
For more information, see Step Failure Strategy Settings
The Failure Strategy of any step in a step group overrides the Failure Strategy of the step group.
If you do not use a step group Failure Strategy, then the Stage's Failure Strategy is applied.
Add looping strategy
Select one of the following Looping Strategy options to run step multiple times with different inputs:
For more information, see Looping Strategies Overview
Select Save. Enter a comment for the changes and then select Save.
Add the step group template to a pipeline
You can use the step group template in any pipeline within your project.
To add a step group template to a pipeline:
- Go to the pipeline, and then select the stage where you want to add the template.
- Select Add Step.
- Select Use template.
- Select your step group template from the list of templates.
- Select Use Template.
- Enter a name for the template and select Apply Changes.
- Select Save. Your pipeline now includes a reference to the template.