Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

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


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.

Nested step groups

Containerized step groups cannot have nested step groups. You can put groups of steps next to each other in a containerized step group.

The steps inside each group run in parallel, and each group runs serially.

Step group named Group 1 with HTTP steps HEAD and DELETE side by side, followed by HTTP steps Serial and OPTIONS side by side

Go to Containerize step groups to configure a containerized step group.


Visual summary

This short video walks through step groups.

Step groups in a pipeline stage

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:

  1. In your stage, go to Execution -> Add Step -> Add Step Group.

    Add step menu with the Add Step and Add Step Group options
  2. 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:

  1. In the step group Execution section, select Add Step.

  2. 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]>.

Execution input

Execution input is not supported for step group variables.

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.

Step Group Configuration tab with Name set to Group 1 and 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.

Pipeline example: overriding variables in step groups

The following pipeline illustrates how to override service variables. The service definition has two defined variables, svar1 and svar2. The pipeline overrides these variables as follows:

  • The parent step group overrides svar1 with the value fromStepGroup_OverriddenAtParentStepGroup.

  • The parent step group also has a variable svarParent with the value DefinedAtParentLevel. The child step group overrides this with the value OverridenByChildStepGroup.

  • The child step group overrides svar2 with the value fromStepGroup_OverriddenAtChildLevel.

Execution graph of parent and child step groups next to Shell Script logs that print the overridden variable values

Next steps

Last updated

Was this helpful?