Skip to main content
This guide walks you through creating and running your first Tekton Task and Pipeline. You’ll learn the fundamentals by building working examples.

Prerequisites

Before starting, make sure you have:
  • Tekton Pipelines installed on your cluster (installation guide)
  • kubectl configured 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 named print-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:
You should see:
View the detailed logs:
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. Create echo-message-task.yaml:
echo-message-task.yaml
Apply the Task:
Now create a TaskRun that uses this Task with a custom parameter:
echo-taskrun.yaml
Run it:

Your First Pipeline

Pipelines chain multiple Tasks together. Let’s create a Pipeline that uses our echo-message Task twice.

Create the Pipeline

Create greeting-pipeline.yaml:
greeting-pipeline.yaml

Run the Pipeline

Apply the PipelineRun:

Monitor Pipeline Execution

Watch the PipelineRun status:
View detailed information:
View logs from individual tasks:
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 the script field instead of command and args:
script-example.yaml
Run it:
Always include set -e in bash scripts to ensure the step fails if any command fails. Use set -euxo pipefail for better debugging output.

Key Concepts Recap

  • 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)
  • 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
  • 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, and object
  • 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.