Back to Pipeline

Variable Substitutions Supported by `Tasks` and `Pipelines`

docs/variables.md

1.12.026.3 KB
Original Source
<!-- --- linkTitle: "Variable Substitutions" weight: 407 --- -->

Variable Substitutions Supported by Tasks and Pipelines

This page documents the variable substitutions supported by Tasks and Pipelines.

For instructions on using variable substitutions see the relevant section of the Tasks doc.

Note: Tekton does not escape the contents of variables. Task authors are responsible for properly escaping a variable's value according to the shell, image or scripting language that the variable will be used in.

Variables available in a Pipeline

VariableDescription
params.<param name>The value of the parameter at runtime.
params['<param name>'](see above)
params["<param name>"](see above)
params.<param name>[*]Get the whole param array or object.
params['<param name>'][*](see above)
params["<param name>"][*](see above)
params.<param name>[i]Get the i-th element of param array. This is alpha feature, set enable-api-fields to alpha to use it.
params['<param name>'][i](see above)
params["<param name>"][i](see above)
params.<object-param-name>[*]Get the value of the whole object param. This is alpha feature, set enable-api-fields to alpha to use it.
params.<object-param-name>.<individual-key-name>Get the value of an individual child of an object param. This is alpha feature, set enable-api-fields to alpha to use it.
tasks.<taskName>.matrix.lengthThe length of the Matrix combination count.
tasks.<taskName>.results.<resultName>The value of the Task's result. Can alter Task execution order within a Pipeline.)
tasks.<taskName>.results.<resultName>[i]The ith value of the Task's array result. Can alter Task execution order within a Pipeline.)
tasks.<taskName>.results.<resultName>[*]The array value of the Task's result. Can alter Task execution order within a Pipeline. Cannot be used in script.)
tasks.<taskName>.results.<resultName>.keyThe key value of the Task's object result. Can alter Task execution order within a Pipeline.)
tasks.<taskName>.matrix.<resultName>.lengthThe length of the matrixed Task's results. (Can alter Task execution order within a Pipeline.)
workspaces.<workspaceName>.boundWhether a Workspace has been bound or not. "false" if the Workspace declaration has optional: true and the Workspace binding was omitted by the PipelineRun.
context.pipelineRun.nameThe name of the PipelineRun that this Pipeline is running in.
context.pipelineRun.namespaceThe namespace of the PipelineRun that this Pipeline is running in.
context.pipelineRun.uidThe uid of the PipelineRun that this Pipeline is running in.
context.pipeline.nameThe name of this Pipeline .
tasks.<pipelineTaskName>.statusThe execution status of the specified pipelineTask, only available in finally tasks. The execution status can be set to any one of the values (Succeeded, Failed, or None) described here.
tasks.<pipelineTaskName>.reasonThe execution reason of the specified pipelineTask, only available in finally tasks. The reason can be set to any one of the values (Failed, TaskRunCancelled, TaskRunTimeout, FailureIgnored, etc ) described here.
tasks.statusAn aggregate status of all the pipelineTasks under the tasks section (excluding the finally section). This variable is only available in the finally tasks and can have any one of the values (Succeeded, Failed, Completed, or None) described here.
context.pipelineTask.retriesThe retries of this PipelineTask.
tasks.<taskName>.outputs.<artifactName>The value of a specific output artifact of the Task
tasks.<taskName>.inputs.<artifactName>The value of a specific input artifact of the Task

Variables available in a Task

VariableDescription
params.<param name>The value of the parameter at runtime.
params['<param name>'](see above)
params["<param name>"](see above)
params.<param name>[*]Get the whole param array or object.
params['<param name>'][*](see above)
params["<param name>"][*](see above)
params.<param name>[i]Get the i-th element of param array. This is alpha feature, set enable-api-fields to alpha to use it.
params['<param name>'][i](see above)
params["<param name>"][i](see above)
params.<object-param-name>.<individual-key-name>Get the value of an individual child of an object param. This is alpha feature, set enable-api-fields to alpha to use it.
results.<resultName>.pathThe path to the file where the Task writes its results data.
results['<resultName>'].path(see above)
results["<resultName>"].path(see above)
workspaces.<workspaceName>.pathThe path to the mounted Workspace. Empty string if an optional Workspace has not been provided by the TaskRun.
workspaces.<workspaceName>.boundWhether a Workspace has been bound or not. "false" if an optionalWorkspace has not been provided by the TaskRun.
workspaces.<workspaceName>.claimThe name of the PersistentVolumeClaim specified as a volume source for the Workspace. Empty string for other volume types.
workspaces.<workspaceName>.volumeThe name of the volume populating the Workspace.
credentials.pathThe path to credentials injected from Secrets with matching annotations.
context.taskRun.nameThe name of the TaskRun that this Task is running in.
context.taskRun.namespaceThe namespace of the TaskRun that this Task is running in.
context.taskRun.uidThe uid of the TaskRun that this Task is running in.
context.task.nameThe name of this Task.
context.task.retry-countThe current retry number of this Task.
steps.step-<stepName>.exitCode.pathThe path to the file where a Step's exit code is stored.
steps.step-unnamed-<stepIndex>.exitCode.pathThe path to the file where a Step's exit code is stored for a step without any name.
artifacts.pathThe path to the file where the Task writes its artifacts data.

Fields that accept variable substitutions

CRDField
Taskspec.steps[].name
Taskspec.steps[].image
Taskspec.steps[].imagePullPolicy
Taskspec.steps[].command
Taskspec.steps[].args
Taskspec.steps[].script
Taskspec.steps[].onError
Taskspec.steps[].env.value
Taskspec.steps[].env.valueFrom.secretKeyRef.name
Taskspec.steps[].env.valueFrom.secretKeyRef.key
Taskspec.steps[].env.valueFrom.configMapKeyRef.name
Taskspec.steps[].env.valueFrom.configMapKeyRef.key
Taskspec.steps[].volumeMounts.name
Taskspec.steps[].volumeMounts.mountPath
Taskspec.steps[].volumeMounts.subPath
Taskspec.volumes[].name
Taskspec.volumes[].configMap.name
Taskspec.volumes[].configMap.items[].key
Taskspec.volumes[].configMap.items[].path
Taskspec.volumes[].secret.secretName
Taskspec.volumes[].secret.items[].key
Taskspec.volumes[].secret.items[].path
Taskspec.volumes[].persistentVolumeClaim.claimName
Taskspec.volumes[].projected.sources.configMap.name
Taskspec.volumes[].projected.sources.secret.name
Taskspec.volumes[].projected.sources.serviceAccountToken.audience
Taskspec.volumes[].csi.nodePublishSecretRef.name
Taskspec.volumes[].csi.volumeAttributes.*
Taskspec.sidecars[].name
Taskspec.sidecars[].image
Taskspec.sidecars[].imagePullPolicy
Taskspec.sidecars[].env.value
Taskspec.sidecars[].env.valueFrom.secretKeyRef.name
Taskspec.sidecars[].env.valueFrom.secretKeyRef.key
Taskspec.sidecars[].env.valueFrom.configMapKeyRef.name
Taskspec.sidecars[].env.valueFrom.configMapKeyRef.key
Taskspec.sidecars[].volumeMounts.name
Taskspec.sidecars[].volumeMounts.mountPath
Taskspec.sidecars[].volumeMounts.subPath
Taskspec.sidecars[].command
Taskspec.sidecars[].args
Taskspec.sidecars[].script
Taskspec.workspaces[].mountPath
TaskRunspec.workspaces[].subPath
TaskRunspec.workspaces[].persistentVolumeClaim.claimName
TaskRunspec.workspaces[].configMap.name
TaskRunspec.workspaces[].configMap.items[].key
TaskRunspec.workspaces[].configMap.items[].path
TaskRunspec.workspaces[].secret.secretName
TaskRunspec.workspaces[].secret.items[].key
TaskRunspec.workspaces[].secret.items[].path
TaskRunspec.workspaces[].projected.sources[].secret.name
TaskRunspec.workspaces[].projected.sources[].secret.items[].key
TaskRunspec.workspaces[].projected.sources[].secret.items[].path
TaskRunspec.workspaces[].projected.sources[].configMap.name
TaskRunspec.workspaces[].projected.sources[].configMap.items[].key
TaskRunspec.workspaces[].projected.sources[].configMap.items[].path
TaskRunspec.workspaces[].csi.driver
TaskRunspec.workspaces[].csi.nodePublishSecretRef.name
Pipelinespec.tasks[].params[].value
Pipelinespec.tasks[].matrix.params[].value
Pipelinespec.tasks[].matrix.include[].params[].value
Pipelinespec.tasks[].displayName
Pipelinespec.tasks[].workspaces[].subPath
Pipelinespec.tasks[].when[].input
Pipelinespec.tasks[].when[].values
Pipelinespec.tasks[].taskRef.params[].values
Pipelinespec.tasks[].taskRef.name
Pipelinespec.tasks[].onError
Pipelinespec.finally[].params[].value
Pipelinespec.finally[].matrix.params[].value
Pipelinespec.finally[].matrix.include[].params[].value
Pipelinespec.finally[].displayName
Pipelinespec.finally[].workspaces[].subPath
Pipelinespec.finally[].when[].input
Pipelinespec.finally[].when[].values
Pipelinespec.finally[].taskRef.params[].values
Pipelinespec.finally[].taskRef.name
Pipelinespec.finally[].onError
PipelineRunspec.workspaces[].subPath
PipelineRunspec.workspaces[].persistentVolumeClaim.claimName
PipelineRunspec.workspaces[].configMap.name
PipelineRunspec.workspaces[].configMap.items[].key
PipelineRunspec.workspaces[].configMap.items[].path
PipelineRunspec.workspaces[].secret.secretName
PipelineRunspec.workspaces[].secret.items[].key
PipelineRunspec.workspaces[].secret.items[].path
PipelineRunspec.workspaces[].projected.sources[].secret.name
PipelineRunspec.workspaces[].projected.sources[].secret.items[].key
PipelineRunspec.workspaces[].projected.sources[].secret.items[].path
PipelineRunspec.workspaces[].projected.sources[].configMap.name
PipelineRunspec.workspaces[].projected.sources[].configMap.items[].key
PipelineRunspec.workspaces[].projected.sources[].configMap.items[].path
PipelineRunspec.workspaces[].csi.driver
PipelineRunspec.workspaces[].csi.nodePublishSecretRef.name
PipelineRunspec.taskRunSpecs[].podTemplate.nodeSelector.*
PipelineRunspec.taskRunSpecs[].podTemplate.tolerations[].key
PipelineRunspec.taskRunSpecs[].podTemplate.tolerations[].operator
PipelineRunspec.taskRunSpecs[].podTemplate.tolerations[].value
PipelineRunspec.taskRunSpecs[].podTemplate.tolerations[].effect
PipelineRunspec.taskRunSpecs[].podTemplate.affinity.*
PipelineRunspec.taskRunSpecs[].podTemplate.securityContext.*
PipelineRunspec.taskRunSpecs[].podTemplate.volumes[].name
PipelineRunspec.taskRunSpecs[].podTemplate.volumes[].configMap.name
PipelineRunspec.taskRunSpecs[].podTemplate.volumes[].secret.secretName
PipelineRunspec.taskRunSpecs[].podTemplate.runtimeClassName
PipelineRunspec.taskRunSpecs[].podTemplate.schedulerName
PipelineRunspec.taskRunSpecs[].podTemplate.priorityClassName
PipelineRunspec.taskRunSpecs[].podTemplate.imagePullSecrets[].name
PipelineRunspec.taskRunSpecs[].podTemplate.hostAliases[].ip
PipelineRunspec.taskRunSpecs[].podTemplate.hostAliases[].hostnames[*]
PipelineRunspec.taskRunSpecs[].podTemplate.topologySpreadConstraints[].topologyKey
PipelineRunspec.taskRunSpecs[].podTemplate.topologySpreadConstraints[].whenUnsatisfiable