Created
December 9, 2020 12:39
-
-
Save sturman/dd1ee54c34bd4a0eee06c25cda23d709 to your computer and use it in GitHub Desktop.
Running integration tests using testcontainers on Jenkins with the Kubernetes Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DOCKER_TLS_CERTDIR=""
- disable TLS certificates generation (which is enabled by default since docker 18.09+) indind
container.DOCKER_HOST="tcp://localhost:2375"
- change default value to non-TLS endpoint for testcontainersDOCKER_TLS_VERIFY=0
- disable TLS verification for testcontainerskudos to @fr1zle
https://timmhirsens.de/posts/2019/07/testcontainers_on_jenkins_with_kubernetes/