Last active
May 19, 2024 16:03
-
-
Save lvthillo/bf69fbd53442793091c20bd9b1f7663c to your computer and use it in GitHub Desktop.
Scripted Jenkins pipeline which uses 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
podTemplate(label: 'mypod', containers: [ | |
containerTemplate(name: 'git', image: 'alpine/git', ttyEnabled: true, command: 'cat'), | |
containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', command: 'cat', ttyEnabled: true), | |
containerTemplate(name: 'docker', image: 'docker', command: 'cat', ttyEnabled: true) | |
], | |
volumes: [ | |
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'), | |
] | |
) { | |
node('mypod') { | |
stage('Check running containers') { | |
container('docker') { | |
// example to show you can run docker commands when you mount the socket | |
sh 'hostname' | |
sh 'hostname -i' | |
sh 'docker ps' | |
} | |
} | |
stage('Clone repository') { | |
container('git') { | |
sh 'whoami' | |
sh 'hostname -i' | |
sh 'git clone -b master https://github.com/lvthillo/hello-world-war.git' | |
} | |
} | |
stage('Maven Build') { | |
container('maven') { | |
dir('hello-world-war/') { | |
sh 'hostname' | |
sh 'hostname -i' | |
sh 'mvn clean install' | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment