Overview
Variable substitution allows you to:- Access parameter values at runtime
- Reference Task results in subsequent Tasks
- Use context information about the TaskRun or PipelineRun
- Access workspace paths and bound status
- Retrieve exit codes from previous Steps
Basic Variable Syntax
Variables use the syntax$(variable.name) and can be referenced in most fields of a Task or Pipeline.
Parameter Variables
Access parameter values using:Array Parameters
Access entire arrays or individual elements:Array indexing is an alpha feature. Set
enable-api-fields to alpha to use it.Object Parameters
Access object parameter properties (alpha feature):Pipeline Variables
Task Results
Reference results from previous Tasks:Array Results
Access array results:Object Results
Access object result properties:Context Variables
Task Context Variables
Access information about the current Task and TaskRun:Pipeline Context Variables
Access information about the current Pipeline and PipelineRun:Workspace Variables
Access workspace information:Results Variables
Writing Results
Write results to the path provided by Tekton:Result Path Variables
Step Variables
Access exit codes from previous Steps:Matrix Variables
Access matrix execution information:Finally Task Variables
Infinally tasks, access execution status:
Fields Supporting Variable Substitution
Not all fields support variable substitution. Key supported fields include:Task Fields
spec.steps[].namespec.steps[].imagespec.steps[].commandspec.steps[].argsspec.steps[].scriptspec.steps[].env.valuespec.volumes[].namespec.sidecars[].namespec.sidecars[].image
Pipeline Fields
spec.tasks[].params[].valuespec.tasks[].workspaces[].subPathspec.tasks[].when[].inputspec.tasks[].when[].valuesspec.finally[].params[].value