docs/current_docs/getting-started/ci-integrations/tekton.mdx
Dagger provides a programmable container engine that can be invoked from Tekton to run a Dagger pipeline. This allows you to benefit from Dagger's caching, debugging, and visualization features, whilst still keeping all of your existing Tekton infrastructure.
Tekton provides capabilities which allow you to run a Dagger pipeline as a Tekton Task without needing any external configuration. This integration uses the standard architecture for Tekton and adds a Dagger Engine sidecar which gives each Tekton PipelineRun its own Dagger Engine.
To trigger a pipeline run, you can use the Tekton CLI (tkn), or you can configure events in Tekton to run it automatically as desired.
kubectl profileThe following example builds a simple Go application using a Dagger Function. This project uses the Dagger Go SDK for CI.
Install the git-clone Task from Tekton Hub. This Task adds repository cloning capabilities to the Tekton Pipeline. Use the following command:
tkn hub install task git-clone
Define a new Tekton Pipeline as follows, in a file named git-pipeline.yaml:
This Pipeline references two Tasks:
git-clone Task, to check out the Git repository for the project into a Tekton Workspace;dagger Task, to run the Dagger pipeline for the project (defined below).Define a new Tekton Task as follows, in a file named dagger-task.yaml:
This Tekton Task installs the Dagger CLI and calls a Dagger Function. This Task installs the dependencies needed to execute the Dagger pipeline for the project (which was checked out in the previous Tekton Pipeline) and then calls a Dagger Function to build the project.
In this Tekton Task, the Dagger Engine runs as a sidecar and shares a socket with the Task itself. The Task uses dind as its runtime in order to have Docker available.
Define a new Tekton PipelineRun as follows, in a file named git-pipeline-run.yaml:
This PipelineRun corresponds to the Tekton Pipeline created previously. It executes the Tekton Pipeline with a given set of input parameters: the Git repository URL and an optional Dagger Cloud token.
To apply the configuration and run the Tekton Pipeline, use the following commands:
kubectl apply -f dagger-task.yaml
kubectl apply -f git-pipeline-yaml
kubectl create -f git-pipeline-run.yaml
To see the logs from the PipelineRun, obtain the PipelineRun name from the output and run tkn pipelinerun logs clone-read-run-<id> -f.
If you have any questions about additional ways to use Tekton with Dagger, join our Discord and ask your questions in our Kubernetes channel.
Tekton is a Kubernetes-based framework for creating, managing and running CI/CD pipelines.