- Configuring a
- Code examples
Condition resource in Tekton allows you to conditionalize the execution of
Tasks within a
You define each
Condition within your
PipelineRun definition and then conditionalize
Task in the corresponding
Condition resource runs its own container image that executes the logic that evaluates your chosen condition.
This container runs to completion and must return an exit code value of
0 for the
check to be successful; otherwise
Task as well as its
Task dependencies (defined via
(such as results) do not execute.
Note: Labels and annotations specified in the
Condition's metadata are automatically
propagated to the
Condition definition supports the following fields:
apiVersion- Specifies the API version, for example
kind- Identifies this resource object as a
metadata- Specifies metadata that uniquely identifies this
Conditionobject. For example, a
spec- Specifies the configuration information for this
Conditionresource object. This must include:
check- Specifies a container that you want to run for evaluating this
description- Provides a meaningful description of this
Specifying the condition
check field (required) specifies a single piece of evaluation logic that you want to run before the
Task in your
Pipeline can execute. This field must specify a
You can specify parameters to pass to the
Condition's evaluation logic at run time.
Sub-fields within the
check field can access these parameter values using Tekton’s templating
syntax as follows:
spec: parameters: - name: image default: ubuntu check: image: $(params.image)
- Must only contain alphanumeric characters, hyphens (
-), and underscores (
- Must begin with a letter or an underscore (
fooIs-Bar_ is a valid parameter name, but
0banana are not.
Each declared parameter has a
type field, which can be set to either
string if you don’t specify a value. The
default fields for a
Parameter are optional. The
array type is useful in situations such as checking that a pushed
branch name doesn’t collide with any of the specified protected branch names.
You can specifiy input
PipelineResources in your
Condition definition to
Condition's container step with data or context necessary to run the evaluation logic.
description field (optional) allows you to specify a meaningful description for your
For a better understanding of
Conditions, study our code examples.
Was this page helpful?
Thanks! Tell us how we can further improve.
Sorry about that. Tell us how we can further improve.