Prerequisites
Before starting, make sure you have:- Tekton Pipelines installed on your cluster (installation guide)
kubectlconfigured to access your cluster- Basic familiarity with Kubernetes concepts
Understanding Tasks and TaskRuns
A Task defines a series of steps that execute in order. A TaskRun instantiates and executes a Task. Think of Tasks as templates and TaskRuns as instances.Your First Task
Let’s create a simple Task that prints the current date in two formats.Create the TaskRun
Create a file namedprint-date-taskrun.yaml:
print-date-taskrun.yaml
The
generateName field creates a unique name with a random suffix (e.g., print-date-abc123). This is useful for creating multiple TaskRuns from the same definition.Run the Task
Apply the TaskRun to your cluster:View the Results
Check the TaskRun status:Each step in a Task runs in its own container. The steps execute sequentially in the order defined.
Adding Parameters
Let’s create a Task that accepts parameters for more flexibility. Createecho-message-task.yaml:
echo-message-task.yaml
echo-taskrun.yaml
Your First Pipeline
Pipelines chain multiple Tasks together. Let’s create a Pipeline that uses ourecho-message Task twice.
Create the Pipeline
Creategreeting-pipeline.yaml:
greeting-pipeline.yaml
Run the Pipeline
Apply the PipelineRun:Monitor Pipeline Execution
Watch the PipelineRun status:By default, Pipeline tasks run in parallel unless you specify dependencies with
runAfter. In this example, both greeting tasks run simultaneously.Using Scripts in Steps
For more complex logic, use thescript field instead of command and args:
script-example.yaml
Key Concepts Recap
Tasks vs TaskRuns
Tasks vs TaskRuns
- Task: A reusable template defining steps, parameters, and results
- TaskRun: An execution instance of a Task with specific parameter values
- Tasks can be embedded in TaskRuns (
taskSpec) or referenced by name (taskRef)
Pipelines vs PipelineRuns
Pipelines vs PipelineRuns
- Pipeline: A reusable workflow definition that orchestrates multiple Tasks
- PipelineRun: An execution instance of a Pipeline
- PipelineRuns can embed Pipeline specs or reference named Pipelines
Parameters
Parameters
- Define inputs to Tasks and Pipelines with type checking
- Support default values and descriptions
- Reference parameters using
$(params.PARAM_NAME)syntax - Types include:
string,array, andobject
Results
Results
- Tasks can output results that other Tasks consume
- Write results to
$(results.RESULT_NAME.path) - Pipelines can pass results between Tasks and emit final results
Next Steps
Now that you’ve created your first Tasks and Pipeline, explore more advanced features:Working with Workspaces
Share data between Tasks using Workspaces and persistent volumes
Task Results
Pass data between Tasks using results and parameters
Pipeline Dependencies
Control task execution order with runAfter and when expressions
Official Examples
Browse 100+ examples covering real-world CI/CD scenarios
Cleaning Up
Remove the resources created in this tutorial:TaskRuns and PipelineRuns are retained after completion so you can inspect logs and results. Clean them up periodically or configure automatic cleanup using Tekton’s retention policies.