Example
This pipeline demonstrates both sequential and parallel task execution:upper and lower tasks run in parallel after starter completes.
How It Works
Starter Task Runs First
The
starter task has no runAfter clause, so it begins immediately. It writes the message parameter to a file in the shared workspace.Upper and Lower Run in Parallel
Both
upper and lower tasks declare runAfter: [starter], so they wait for starter to complete. Since they don’t depend on each other, they run in parallel. Both read from the shared workspace and transform the message.Reporter Runs After Upper
The
reporter task waits for upper to complete (via runAfter) and uses its result. It doesn’t use a workspace, so it can be scheduled on any node.Task Execution Timeline
Workspace Sharing
All tasks that use workspaces share the same underlying storage:- starter: Writes to
init/message - upper: Reads from
init/message, writes toupper - lower: Reads from
init/message, writes tolower - validator: Reads from both
upperandlower
Tasks that share a workspace are scheduled to the same node using an Affinity Assistant (unless disabled). This ensures the shared volume is accessible.
Workspace Subpaths
The pipeline uses subpaths to organize data within a single workspace:Expected Output
With parametermessage: "Hello Tekton":
- starter writes:
Hello Tekton - upper produces:
HELLO TEKTON - lower produces:
hello tekton - reporter prints:
HELLO TEKTON - validator verifies both transformations
Key Concepts
- Parallel Execution: Tasks without dependencies run simultaneously
- runAfter: Explicitly declare task dependencies
- Shared Workspaces: Multiple tasks can read/write to the same workspace
- Affinity Assistant: Schedules workspace-using tasks to the same node
- Subpaths: Organize data within a workspace using directory paths
- Task Results vs Workspaces: Results for small data, workspaces for files and large data
Next Steps
- See a real-world multi-stage pipeline
- Learn about building Docker images