Skip to main content
A StepAction is a reusable and scriptable unit of work that is performed by a Step. StepActions enable you to share common Step logic across multiple Tasks.
StepActions is a stable feature.

Overview

A Step is not reusable on its own, but the work it performs can be extracted into a StepAction and referenced by multiple Steps. Key concepts:
  • Steps are inlined in Task definitions and either perform work directly or reference a StepAction
  • A StepAction cannot run standalone (unlike TaskRuns or PipelineRuns)
  • A Step has the ability to reference a StepAction for its work
  • The Step provides orchestration and context to the StepAction

Configuring a StepAction

Required Fields

  • apiVersion - Specifies the API version (e.g., tekton.dev/v1alpha1)
  • kind - Must be StepAction
  • metadata - Uniquely identifies the StepAction (e.g., name)
  • spec - Configuration for the StepAction
  • image - Container image to use for the Step

Optional Fields

  • command - Cannot be used with script
  • args - Command arguments
  • script - Cannot be used with command
  • env - Environment variables
  • params - Parameter declarations
  • results - Result declarations
  • workingDir - Working directory
  • securityContext - Security context
  • volumeMounts - Volume mounts
  • description - User-facing description

Basic Example

Parameters

StepActions declare parameters just like Tasks, supporting string, array, and object types.

Declaring Parameters

Parameters cannot be directly used in script in StepActions. This prevents shell injection attacks. Instead, pass params to environment variables and reference them in scripts.

Passing Parameters to StepActions

Steps provide parameter values to StepActions:
If a Step declares params for an inlined Step (not referencing a StepAction), it will cause a validation error.

Parameter Substitution Order

When applying parameters to a StepAction, substitutions occur in this order:
  1. TaskRun parameter values in step parameters
  2. Step-provided parameter values
  3. Default values that reference other parameters
  4. Simple default values
  5. Step result references

Results

StepActions can declare and emit results.

Declaring Results

StepActions should emit results to $(step.results.<resultName>.path) rather than $(results.<resultName>.path) to avoid name collisions when multiple StepActions are used in the same Task.

Fetching Results from StepActions

Tasks fetch StepAction results using the value field in Task results:
Results emitted to $(step.results.<resultName>.path) are not automatically available as TaskRun results. The Task must explicitly fetch them.

Passing Results Between Steps

Steps can consume results from previous Steps:

Result Reference Syntax

Whole array results (using star notation) cannot be referenced in script and env. Step results can only be referenced in a Step’s/StepAction’s env, command, and args.

Working Directory

Declare a working directory for the StepAction:

Parameterizing Working Directory

Make the working directory configurable:

Security Context

Specify a security context for the StepAction:
The securityContext from StepAction will overwrite the securityContext from TaskRun.

Volume Mounts

Define volume mounts in StepActions. The volume mount name MUST be a single parameter reference:
Valid: $(params.registryConfig) Invalid: $(params.registryConfig)-foo or "unparametrized-name"

Description

Add a user-facing description:

Referencing StepActions

Reference StepActions from Steps using the ref field:

Field Restrictions

When a Step references a StepAction, it CANNOT contain:
  • image
  • command
  • args
  • script
  • env
  • volumeMounts

Allowed Fields with Ref

When referencing a StepAction, a Step CAN contain:
  • computeResources
  • workspaces (Isolated workspaces)
  • volumeDevices
  • imagePullPolicy
  • onError
  • stdoutConfig
  • stderrConfig
  • securityContext
  • envFrom
  • timeout
  • ref
  • params

Remote StepActions

Reference StepActions from remote locations like Git repositories:
Support for remote resolvers depends on what Resolvers your cluster operator has installed. The default resolver type can be configured using the default-resolver-type field in the config-defaults ConfigMap (alpha feature).