Jenkins
Dagger provides a programmable container engine that allows you to replace your Groovy-based Jenkins pipelines with with Dagger Functions written in a regular programming language. This allows you to execute your pipeline the same locally and in Jenkins, with intelligent caching, while keeping all of your existing Jenkins infrastructure.
How it works​
There are many ways to run Dagger on Jenkins. The simplest way to get started is having a Jenkins agent with OCI compatible container runtime.
The general workflow looks like this:
- Jenkins receives job trigger as usual.
 - Jenkins loads 
Jenkinsfilefrom repository or from UI configuration. - Jenkins parses the Groovy-based 
Jenkinsfileand downloads the Dagger CLI. - Jenkins find and executes one (or more) Dagger CLI commands, such as 
dagger call .... - The Dagger CLI attempts to find an existing Dagger Engine or spins up a new one inside the Jenkins agent.
 - The Dagger CLI calls the specified Dagger Function and sends telemetry to Dagger Cloud if the 
DAGGER_CLOUD_TOKENenvironment variable is set. - Job completes with success or failure, pipeline logs appear in Jenkins as usual
 
Prerequisites​
Running the examples shown below requires:
- At least one Jenkins agent with the 
daggerlabel - A Docker engine that is able to run containers (can be 
docker:dind) - The 
dockerclient installed on your Jenkins agent 
Example​
The following code sample demonstrates how to integrate Dagger with Jenkins.
pipeline {
  agent { label 'dagger' }
  // assumes that the Dagger Cloud token
  // is in a Jenkins credential named DAGGER_CLOUD_TOKEN
  environment {
    DAGGER_VERSION = "0.19.4"
    PATH = "/tmp/dagger/bin:$PATH"
    DAGGER_CLOUD_TOKEN =  credentials('DAGGER_CLOUD_TOKEN')
  }
  stages {
    stage("dagger") {
      steps {
        sh '''
          curl -fsSL https://dl.dagger.io/dagger/install.sh | BIN_DIR=/tmp/dagger/bin DAGGER_VERSION=$DAGGER_VERSION sh
          dagger call -m github.com/shykes/hello hello --greeting "bonjour" --name "from jenkins"
        '''
      }
    }
  }
}
Resources​
If you have any questions about additional ways to use Jenkins with Dagger, join our Discord and ask your questions in our Jenkins channel.
- Introduction to running Dagger Pipelines with Jenkins by Lev Lazinskiy. In this demo, he shows how to integrate Dagger pipelines with Jenkins. He explains the setup process for a Jenkins pipeline using Dagger and covers both a simple and a modular approach to managing CI pipelines effectively.
 
About Jenkins​
Jenkins is an open-source automation server that enables teams to automate the build, test, and deploy processes of software projects. Jenkins supports many plugins that integrate with various tools, making it a popular choice for Continuous Integration and Continuous Deployment.