Pipeline is a collection of Tasks that you define and arrange in a specific order of execution as part of your continuous integration flow.
Overview
EachTask in a Pipeline executes as a Pod on your Kubernetes cluster. You can configure various execution conditions to fit your business needs.
Pipeline Configuration
APipeline definition supports the following fields:
Required Fields
Specifies the API version, for example
tekton.dev/v1 or tekton.dev/v1beta1.Identifies this resource object as a
Pipeline object.Specifies metadata that uniquely identifies the Pipeline object. For example, a
name.Specifies the configuration information for this Pipeline object.
Specifies the Tasks that comprise the Pipeline and the details of their execution.
Optional Fields
Specifies the Parameters that the Pipeline requires.
Specifies a set of Workspaces that the Pipeline requires.
Specifies the location to which the Pipeline emits its execution results.
Holds an informative description of the Pipeline object.
Specifies one or more Tasks to be executed in parallel after all other tasks have completed.
Specifying Workspaces
Workspaces allow you to specify one or more volumes that each Task in the Pipeline requires during execution:
Specifying Parameters
You can specify global parameters that you want to supply to thePipeline at execution time. Parameters are passed to the Pipeline from its corresponding PipelineRun.
Parameter Format
Parameter names:- Must only contain alphanumeric characters, hyphens (
-), and underscores (_) - Must begin with a letter or an underscore (
_)
Parameter Types
Each declared parameter has atype field, which can be set to array, string, or object.
Example Pipeline with Parameters
Adding Tasks to the Pipeline
YourPipeline definition must reference at least one Task. Each Task within a Pipeline must have a valid name and a taskRef or a taskSpec.
Using taskRef
Using taskSpec
Specifying Parameters in Tasks
You can provide parameters to Tasks:Using the runAfter Field
If you need yourTasks to execute in a specific order within the Pipeline, use the runAfter field to indicate that a Task must execute after one or more other Tasks.
Using the retries Field
For eachTask in the Pipeline, you can specify the number of times Tekton should retry its execution when it fails:
Guard Task Execution using when Expressions
To run aTask only when certain conditions are met, you can guard task execution using the when field.
Components of when Expressions
| Component | Description | Syntax |
|---|---|---|
input | Input for the when expression | Static values or variables (parameters or results) |
operator | Represents an input’s relationship to values | in or notin |
values | An array of string values | Array of static values or variables |
Examples
Using Results
Tasks can emit Results when they execute. A Pipeline can use these Results for two purposes:- Pass the Result of a Task into the Parameters or when expressions of another
- Emit Results and include data from the Results of its Tasks
Passing Results Between Tasks
Emitting Results from a Pipeline
Configuring Task Timeout
You can use thetimeout field in the Task spec within the Pipeline to set the timeout of the TaskRun:
Adding Finally to the Pipeline
You can specifyfinally tasks that should execute after all the Tasks in your Pipeline have completed:
Finally Tasks Features
finallytasks are executed in parallelfinallytasks are guaranteed to execute after all pipeline tasks completefinallytasks can access execution status of pipeline tasksfinallytasks support when expressions