Getting Started with Pipelines

Create and run your first Tekton pipeline

This tutorial shows you how to:

  • Create two tasks.
  • Create a pipeline containing your tasks.
  • Use PipelineRun to instantiate and run the pipeline containing your tasks.

For this tutorial we are going to use minikube to run the commands locally.


Creating and running a second task

You already have a Hello World! task. To create a second Goodbye World! task:

  1. Create a new file named goodbye-world.yaml and add the following content:

    kind: Task
      name: goodbye
        - name: goodbye
          image: ubuntu
          script: |
            echo "Goodbye World!"        
  2. Apply your task file:

    kubectl apply --filename goodbye-world.yaml

When a task is part of a pipeline you don’t have to instantiate it, the pipeline is going to take care of that.

Creating and running a pipeline

A pipeline defines an ordered series of tasks arranged in a specific execution order as part of your CI/CD workflow.

In this section you are going to create your first pipeline, that will include both the Hello World! and Goodbye World! tasks.

  1. Create a new file named hello-goodbye-pipeline.yaml and add the following content:

    kind: Pipeline
      name: hello-goodbye
        - name: hello
            name: hello
        - name: goodbye
            - hello
            name: goodbye
  2. Apply your pipeline configuration to your cluster:

    kubectl apply --filename hello-goodbye-pipeline.yaml
  3. Instantiate your pipeline with a PipelineRun object. Create a new file named hello-goodbye-pipeline-run.yaml with the following content:

    kind: PipelineRun
      name: hello-goodbye-run
        name: hello-goodbye
  4. Start your pipeline by applying the PipelineRun configuration to your cluster:

    kubectl apply --filename hello-goodbye-pipeline-run.yaml

    You see the following output: created

    Tekton now starts running your pipeline.

  5. To see the logs of the PipelineRun, use the following command:

    tkn pipelinerun logs hello-goodbye-run -f -n default

    The output shows both Tasks completed successfully:

    [hello : hello] Hello World!
    [goodbye : goodbye] Goodbye World!


To delete the cluster that you created for this quickstart run:

minikube delete

The output confirms that your cluster was deleted:

🔥  Deleting "minikube" in docker ...
🔥  Deleting container "minikube" ...
🔥  Removing /home/user/.minikube/machines/minikube ...
💀  Removed all traces of the "minikube" cluster.

Further reading

Other useful resources