Getting Started with Pipelines
This tutorial shows you how to:
- Create two Tasks.
- Create a Pipeline containing your Tasks.
- Use
PipelineRunto instantiate and run the Pipeline containing your Tasks.
This guide uses a local cluster with minikube.
Prerequisites
-
Complete the Getting started with Tasks tutorial. Do not clean up your resources, skip the last section.
Create and run a second Task
You already have a “Hello World!” Task. To create a second “Goodbye!” Task:
-
Create a new file named
goodbye-world.yamland add the following content:apiVersion: tekton.dev/v1 kind: Task metadata: name: goodbye spec: params: - name: username type: string steps: - name: goodbye image: ubuntu script: | #!/bin/bash echo "Goodbye $(params.username)!"This Task takes one parameter,
username. Whenever this Task is used a value for that parameter must be passed to the Task. -
Apply the Task file:
kubectl apply --filename goodbye-world.yaml
When a Task is part of a Pipeline, Tekton creates a TaskRun object for every
task in the Pipeline.
Create and run a Pipeline
A Pipeline defines an ordered series of Tasks arranged in a specific execution order as part of the CI/CD workflow.
In this section you are going to create your first Pipeline, that will include both the “Hello World!” and “Goodbye!” Tasks.
-
Create a new file named
hello-goodbye-pipeline.yamland add the following content:apiVersion: tekton.dev/v1 kind: Pipeline metadata: name: hello-goodbye spec: params: - name: username type: string tasks: - name: hello taskRef: name: hello - name: goodbye runAfter: - hello taskRef: name: goodbye params: - name: username value: $(params.username)The Pipeline defines the parameter
username, which is then passed to thegoodbyeTask. -
Apply the Pipeline configuration to your cluster:
kubectl apply --filename hello-goodbye-pipeline.yaml -
A PipelineRun, represented in the API as an object of kind
PipelineRun, sets the value for the parameters and executes a Pipeline. To create PipelineRun, create a new file namedhello-goodbye-pipeline-run.yamlwith the following:apiVersion: tekton.dev/v1 kind: PipelineRun metadata: name: hello-goodbye-run spec: pipelineRef: name: hello-goodbye params: - name: username value: "Tekton"This sets the actual value for the
usernameparameter:"Tekton". -
Start the Pipeline by applying the
PipelineRunconfiguration to your cluster:kubectl apply --filename hello-goodbye-pipeline-run.yamlYou see the following output:
pipelinerun.tekton.dev/hello-goodbye-run createdTekton now starts running the Pipeline.
-
To see the logs of the
PipelineRun, use the following command:tkn pipelinerun logs hello-goodbye-run -f -n defaultThe output shows both Tasks completed successfully:
[hello : echo] Hello World! [goodbye : goodbye] Goodbye Tekton!
Cleanup
To learn about Tekton Triggers, skip this section and proceed to the next tutorial.
To delete the cluster that you created for this guide run:
minikube delete
The output confirms that the cluster was deleted:
🔥 Deleting "minikube" in qemu2 ... 💀 Removed all traces of the "minikube" cluster.
Further reading
We recommend that you complete Getting started with Triggers.
For more complex examples check:
Feedback
Was this page helpful?