2022-03-03 15:01:18 +01:00
---
2022-03-04 19:26:12 +01:00
slug: /1201/ci-environment
2022-04-13 15:58:51 +02:00
displayed_sidebar: '0.2'
2022-03-03 15:01:18 +01:00
---
2022-03-28 12:03:31 +02:00
# Integrating with your CI environment
2022-03-03 15:01:18 +01:00
2022-03-28 12:05:15 +02:00
Dagger can be used with any CI environment (no migration required) and has two important advantages which make the overall experience less error-prone and more efficient:
2022-03-07 16:42:15 +01:00
2022-03-29 12:36:48 +02:00
1. You don't write YAML, you write [CUE ](https://cuelang.org/ ) - typed configuration with built-in formatting
2022-03-10 17:27:52 +01:00
2. Configuration is executed in [BuildKit ](https://github.com/moby/buildkit ), the execution engine at the heart of Docker
2022-03-07 16:42:15 +01:00
This makes any CI environment with Docker pre-installed work with Dagger out of the box.
We started with [CI environments that you told us you are using ](https://github.com/dagger/dagger/discussions/1677 ).
We will configure a production deployment for the same application that we covered in the previous page.
:::note
If you cannot find your CI environment below, [let us know via this GitHub discussion ](https://github.com/dagger/dagger/discussions/1677 ).
:::
2022-03-03 15:01:18 +01:00
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
< Tabs defaultValue = "github-actions"
2022-03-04 19:26:12 +01:00
groupId="ci-environment"
2022-03-03 15:01:18 +01:00
values={[
{label: 'GitHub Actions', value: 'github-actions'},
{label: 'CircleCI', value: 'circleci'},
{label: 'GitLab', value: 'gitlab'},
2022-03-07 16:42:15 +01:00
{label: 'Jenkins', value: 'jenkins'},
{label: 'Tekton', value: 'tekton'},
2022-03-03 15:01:18 +01:00
]}>
< TabItem value = "github-actions" >
2022-03-10 17:27:52 +01:00
```yaml file=../tests/getting-started/github-actions.yml title=".github/workflows/todoapp.yml"
2022-03-28 12:03:31 +02:00
2022-03-07 16:42:15 +01:00
```
2022-03-03 15:01:18 +01:00
< / TabItem >
< TabItem value = "circleci" >
2022-03-07 16:42:15 +01:00
If you would like us to document CircleCI next, vote for it here: [dagger#1677 ](https://github.com/dagger/dagger/discussions/1677 )
2022-03-03 15:01:18 +01:00
< / TabItem >
< TabItem value = "gitlab" >
2022-03-30 23:45:53 +02:00
```yaml
.docker:
2022-04-13 15:58:51 +02:00
image: docker:${DOCKER_VERSION}-git
services:
- docker:${DOCKER_VERSION}-dind
variables:
# See https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#docker-in-docker-with-tls-enabled-in-the-docker-executor
DOCKER_HOST: tcp://docker:2376
2022-03-30 23:45:53 +02:00
2022-04-13 15:58:51 +02:00
DOCKER_TLS_VERIFY: '1'
DOCKER_TLS_CERTDIR: '/certs'
DOCKER_CERT_PATH: '/certs/client'
2022-03-30 23:45:53 +02:00
2022-04-13 15:58:51 +02:00
# Faster than the default, apparently
DOCKER_DRIVER: overlay2
2022-03-30 23:45:53 +02:00
2022-04-13 15:58:51 +02:00
DOCKER_VERSION: '20.10'
2022-03-30 23:45:53 +02:00
.dagger:
2022-04-13 15:58:51 +02:00
extends: [.docker]
variables:
DAGGER_VERSION: 0.2.4
DAGGER_LOG_FORMAT: plain
DAGGER_CACHE_PATH: .dagger-cache
ARGS: ''
cache:
key: dagger-${CI_JOB_NAME}
paths:
- ${DAGGER_CACHE_PATH}
before_script:
- apk add --no-cache curl
- |
# install dagger
cd /usr/local
curl -L https://dl.dagger.io/dagger/install.sh | sh
cd -
dagger version
script:
- dagger project update
- |
dagger \
do \
--cache-from type=local,src=${DAGGER_CACHE_PATH} \
--cache-to type=local,mode=max,dest=${DAGGER_CACHE_PATH} \
${ARGS}
2022-03-30 23:45:53 +02:00
build:
2022-04-13 15:58:51 +02:00
extends: [.dagger]
variables:
ARGS: build
2022-03-30 23:45:53 +02:00
```
2022-03-07 16:42:15 +01:00
< / TabItem >
< TabItem value = "jenkins" >
2022-04-09 00:38:17 +02:00
With `docker` and `dagger` installed on your Jenkins agent.
```groovy
pipeline {
agent any
environment {
//https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#handling-credentials
//e.g.
//DH_CREDS=credentials('jenkins-dockerhub-creds')
//AWS_ACCESS_KEY_ID = credentials('jenkins-aws-secret-key-id')
//AWS_SECRET_ACCESS_KEY = credentials('jenkins-aws-secret-access-key')
}
stages {
stage("setup") {
steps {
//only needed if you don't commit the cue.mod directory to git
//sh '''
// dagger project init
// dagger project update
//'''
}
}
stage("do") {
steps {
//substitute your action name for 'helloworld'
//e.g. 'build' or 'push' or whatever you've created!
sh 'dagger do helloworld --log-format=plain'
}
}
}
}
```
2022-03-07 16:42:15 +01:00
< / TabItem >
< TabItem value = "tekton" >
If you would like us to document Tekton next, vote for it here: [dagger#1677 ](https://github.com/dagger/dagger/discussions/1677 )
2022-03-03 15:01:18 +01:00
< / TabItem >
< / Tabs >