Skip to content

Instantly share code, notes, and snippets.

@sturman
Created December 9, 2020 12:39
Show Gist options
  • Save sturman/dd1ee54c34bd4a0eee06c25cda23d709 to your computer and use it in GitHub Desktop.
Save sturman/dd1ee54c34bd4a0eee06c25cda23d709 to your computer and use it in GitHub Desktop.
Running integration tests using testcontainers on Jenkins with the Kubernetes Plugin
def pod =
"""
apiVersion: v1
kind: Pod
metadata:
labels:
name: worker
spec:
serviceAccountName: jenkins
containers:
- name: maven
image: maven:3.6.3-jdk-8
resources:
requests:
cpu: "1000m"
memory: "2048Mi"
imagePullPolicy: Always
tty: true
command: ["cat"]
- name: dind
image: docker:dind
imagePullPolicy: Always
tty: true
env:
- name: DOCKER_TLS_CERTDIR
value: ""
securityContext:
privileged: true
"""
pipeline {
agent {
kubernetes {
yaml pod
}
}
options {
skipStagesAfterUnstable()
}
environment {
DOCKER_HOST = 'tcp://localhost:2375'
DOCKER_TLS_VERIFY = 0
}
stages {
stage('Test') {
steps {
container('maven') {
script {
sh "mvn test -P integration"
}
}
}
post {
always {
junit '**/surefire-reports/TEST-*.xml'
}
}
}
}
}
@sturman
Copy link
Author

sturman commented Dec 9, 2020

DOCKER_TLS_CERTDIR="" - disable TLS certificates generation (which is enabled by default since docker 18.09+) in dind container.
DOCKER_HOST="tcp://localhost:2375" - change default value to non-TLS endpoint for testcontainers
DOCKER_TLS_VERIFY=0 - disable TLS verification for testcontainers

kudos to @fr1zle
https://timmhirsens.de/posts/2019/07/testcontainers_on_jenkins_with_kubernetes/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment