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.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tektoncd/pipeline/llms.txt
Use this file to discover all available pages before exploring further.
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 beStepActionmetadata- Uniquely identifies the StepAction (e.g.,name)spec- Configuration for the StepActionimage- Container image to use for the Step
Optional Fields
command- Cannot be used withscriptargs- Command argumentsscript- Cannot be used withcommandenv- Environment variablesparams- Parameter declarationsresults- Result declarationsworkingDir- Working directorysecurityContext- Security contextvolumeMounts- Volume mountsdescription- User-facing description
Basic Example
Parameters
StepActions declare parameters just like Tasks, supporting string, array, and object types.Declaring Parameters
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:- TaskRun parameter values in step parameters
- Step-provided parameter values
- Default values that reference other parameters
- Simple default values
- 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 thevalue field in Task results:
Passing Results Between Steps
Steps can consume results from previous Steps:Result Reference Syntax
| Result Type | Parameter Type | Syntax | API Fields Required |
|---|---|---|---|
| string | string | $(steps.<step-name>.results.<result-name>) | stable |
| array | array | $(steps.<step-name>.results.<result-name>[*]) | alpha or beta |
| array | string | $(steps.<step-name>.results.<result-name>[i]) | alpha or beta |
| object | string | $(tasks.<task-name>.results.<result-name>.key) | alpha or beta |
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:Volume Mounts
Define volume mounts in StepActions. The volume mountname 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 theref field:
Field Restrictions
When a Step references a StepAction, it CANNOT contain:imagecommandargsscriptenvvolumeMounts
Allowed Fields with Ref
When referencing a StepAction, a Step CAN contain:computeResourcesworkspaces(Isolated workspaces)volumeDevicesimagePullPolicyonErrorstdoutConfigstderrConfigsecurityContextenvFromtimeoutrefparams
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).