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

Stage

Stages are the primary execution blocks within a Harness pipeline. Each stage groups related steps and has its own runtime, settings, and configuration.

A stage is the primary building block inside a pipeline. Each stage contains one or more steps that execute in sequence, along with its own runtime configuration, failure strategy, and condition settings.

Pipelines are built by connecting stages on the canvas. You can run stages serially, group them to run in parallel, or chain them with conditional logic.

What you will learn

  • How to add a stage to a pipeline and choose a starting stage type

  • What configuration sections are available on every stage

  • How to use stage inputs, outputs, and environment variables to pass data between stages

  • How execution controls (strategy, concurrency, failure handling, conditional execution, timeout) apply at the stage level

  • How to configure the runtime environment for a stage


Add a stage

To add a stage to a pipeline:

  1. Open the pipeline in Pipeline Studio.

  2. On the canvas, select the + (plus) button between the start and end nodes.

  3. In the Add stage panel, choose the stage type you want to start with.

  4. Configure the stage and select Add stage.


Stage types

When you add a stage, Harness prompts you to choose a starting type. The type sets up an initial configuration; it does not lock the stage to a specific purpose. For example, a Build stage can also run deployment steps, and a Deploy stage can run scripts or tests.

Type
Description

Starts with an empty stage. Add any step types manually. Use this when none of the other types fit your use case.

Applies a pre-built stage template from the template library. The stage inherits all steps and settings defined in the template.

Pre-configured for compiling, testing, and validating code. Expands the Code & build section with source connector and infrastructure settings.

Pre-configured for deploying services to environments. Expands the Deploy section with service, environment, and infrastructure fields.

Runs another pipeline as a stage within this one. The child pipeline executes in full and its status determines whether this stage passes or fails.

Creates a container that holds multiple stages running one after another in sequence.

Creates a container that holds multiple stages running simultaneously.

The stage type you select at creation is a starting point, not a constraint. You can add any step type to any stage regardless of which type you chose when creating it.


Stage configuration

After choosing a type, the Add Stage panel shows all available configuration sections. Each section is collapsible.

Section
Description

Name / Id

The display name and unique identifier for the stage. The ID is auto-suggested from the name and is used in expressions and YAML.

Service, environment, and infrastructure definition settings. Shown when the stage type is Deploy or a blank canvas.

Source connector, build infrastructure, and code scanning settings. Shown when the stage type is Build or a blank canvas.

Stage-level input parameters, output values, and environment variables.

Looping strategy, concurrency, failure handling, conditional execution, and timeout.

Where the stage runs: platform OS/arch, runtime type, and shared paths.


Inputs & outputs

The Inputs & outputs section defines the data that flows into and out of a stage.

Field
Description

Inputs

Typed parameters the stage accepts at runtime. Reference them in steps using ${{ inputs.<name> }}.

Outputs

Values the stage exports after it completes. Downstream stages and steps can reference these using ${{ stages.<stage-id>.outputs.<name> }}.

Environment variables

Key-value pairs injected as environment variables into all steps in the stage.

Stage inputs and outputs make it possible to build modular pipelines where data passes cleanly between stages without hardcoding values inside steps.


Execution controls

The Execution controls section configures how and when the stage runs.

Setting
Description

Strategy

Looping strategy for the stage: matrix, for loop, or while loop. Runs the stage multiple times with different inputs.

Concurrency

Limits how many loop iterations run simultaneously when a looping strategy is applied.

On failure

What Harness does if the stage fails: abort the pipeline, retry the stage, ignore the failure, or mark it as success.

Conditional execution

An expression or condition that must evaluate to true for the stage to run. If it evaluates to false, the stage is skipped.

Timeout duration

Maximum time the stage is allowed to run before Harness terminates it. Default is 24h. Accepts duration format: 30m, 2h, 1d.


Runtime Environment

The Runtime Environment section controls where the stage executes.

Setting
Description

Platform

The OS and architecture for the stage runner, for example, Linux/amd64 or macOS/arm64.

Runtime

The infrastructure type: Cloud (Harness-hosted), Docker, a Kubernetes cluster, or a local Harness Delegate.

Shared paths

Additional filesystem paths mounted and shared across all steps in the stage. Useful for passing files between steps that run in separate containers.

The runtime configuration set here applies to all steps in the stage unless a step overrides it with its own container or delegate settings.


Next steps

  • Go to Steps overview to review step types available inside a stage.

  • Go to Strategy to run a stage multiple times with matrix, for, or while loops.

Last updated

Was this helpful?