Group steps using step groups
Add steps to a pipeline individually or as a step group, and run the steps serially or in parallel.
You can add steps to a Continuous Delivery (CD) pipeline individually or together in a step group. Individual steps and steps in a step group can run serially or in parallel.
Unlike an individual step, a step group can apply conditional execution and a failure strategy to every step in the group. You can also run pipeline stages in parallel and deploy multiple services at the same time. Go to synchronize deployments using barriers to control that flow. This topic describes how to add a step group in a stage.
What you will learn from this topic
How to run steps in parallel inside a step group
How to use a containerized step group on your own Kubernetes cluster
How to reference step group variables, output variables, and step group expressions
How to set conditional execution and a failure strategy for every step in the group
How to reference a step setting with the step group ID in the expression
How to override service variables for the duration of the step group
How to add and name a step group, then add steps so the group runs in the stage
Before you begin
Confirm the following before you add a step group:
Supported stages: Harness supports step groups in Build, Deploy, and Custom stages only. Go to step groups to review platform step group behavior.
Kubernetes CD quickstart: Review Kubernetes CD quickstart before you add step groups.
Run steps in parallel
You can run steps in parallel in cases such as the following:
Simulate load with multiple HTTP steps.
Run multiple Verify steps for different providers (AppDynamics, Splunk, Prometheus, and others).
Run independent steps that do not need to run serially.
Run multiple Kubernetes Apply steps to deploy multiple Kubernetes resources at once.
Delete multiple resources at once. Go to delete Kubernetes resources to remove them.
Create or update multiple Jira issues with the Jira Create and Jira Update steps.
Provision multiple resources with Terraform. Go to provision with the Terraform Apply step to configure the Apply step.
Save time when steps are independent. You might have 5 steps and run steps 2 and 3 in parallel because they do not depend on each other. Step 4 runs after those steps complete.
Containerized step groups
By default, Harness runs CD step tasks on the Harness Delegate host system, for example, the Kubernetes cluster where a Kubernetes delegate is running.
To provide greater control over the resources used for CD steps, you can use your own Kubernetes cluster as the runtime infrastructure for those steps.
You can use a CD step group that points to your cluster as the runtime infrastructure. In that step group, add the steps that containerized step groups support.
The steps inside each group run in parallel, and each group runs serially.

Go to Containerize step groups to configure a containerized step group.
Visual summary
This short video walks through step groups.
Add a step group
Add a step group in the stage execution, then add the steps that run inside it. Conditional execution and failure strategy on the group apply to those steps unless a step sets its own.
Add and name the step group
Perform the following steps to add and name a step group:
In your stage, go to Execution -> Add Step -> Add Step Group.

Add step menu with the Add Step and Add Step Group options Enter a name for the step group.
The step group settings appear.
Add steps to the step group
Perform the following steps to add steps to the step group:
In the step group Execution section, select Add Step.
Select a step and configure its Advanced settings.
A step's Advanced settings override the Advanced settings of the step group.
Conditional execution
A step group can have its own conditional execution settings, separate from the conditional execution settings for the stage. The conditional execution settings of the step group apply to all of its steps.
Go to Define conditional executions for stages and steps to configure skip conditions.
The conditional execution settings of any step in a step group override the conditional execution settings of the step group.
If you do not use step group conditional execution settings, Harness uses the stage conditional execution settings.
Step group 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 or stage.
Go to Define a failure strategy on stages and steps to configure the failure strategy.
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, Harness uses the stage failure strategy.
Step group variables
Step group variables are custom variables that you can add and refer to in your pipeline. They are available across the pipeline.
You can add variables of type string, secret, or number to a step group. Their values can be a fixed value, a runtime input, or an expression.
Refer to step group variables within the step group with this expression: <+execution.steps.[step group id].variables.[variable name]>.
Refer to step group variables outside the step group with this expression: <+pipeline.stages.[stage Id].spec.execution.steps.[step group id].variables.[variable name]>.
Output variables
You can reference step group output variables with expressions that use the step group name. A sample expression is <+execution.steps.<stepGroupID>.steps.stepID.outputVariables.[variable name]>.
If you access the output variable from a step in the same step group, you can use a shorter notation: <+stepGroup.steps.step1Identifier.output.outputVariables.[variable name]>.
If the step group is configured as a loop, Harness adds an index at the end of the identifier to identify the unique loop instance. Use this index to reference output variables. For example, <+execution.steps.<stepGroupID_[index]>.steps.stepID.outputVariables.[variable name]>.
Step group expressions
The following expressions are for step groups in pipeline stages:
<+stepGroup.variables>: References a collection of variables within the step group.<+stepGroup.getParentStepGroup>: References a collection of variables from the parent of the step group.
Reference steps in a step group
To reference a step in a step group, use the step group ID in the step's fully qualified name (FQN). The following image shows a step group with the ID Group1.

The FQN format is:
<+pipeline.stages.[stage Id].spec.execution.steps.[step group Id].steps.[step Id].[step setting name]>
For example, to reference the URL setting in an HTTP step in a step group with the ID Group1, the FQN is:
<+pipeline.stages.HTTP.spec.execution.steps.Group1.steps.OPTIONS.spec.url>
Override service variables in step groups
You can customize and override service variables during step group execution. The expression <+serviceVariableOverrides.VARIABLE_NAME> overrides the original value of VARIABLE_NAME. You can use this expression in values YAML files and in other parts of the pipeline where variables are used.
Next steps
Containerize step groups: Run CD steps on a Kubernetes cluster that you manage.
Synchronize deployments using barriers: Coordinate stages that run in parallel.
Define conditional executions for stages and steps: Set skip conditions for a step group or for an individual step.
Define a failure strategy on stages and steps: Choose what the step group does when a step fails.
Last updated
Was this helpful?
