Forked from iocanel/kubernetes-plugin-advanced.groovy
Created
August 7, 2018 18:20
-
-
Save OlegGorj/965539f12b753a83c3fbfa2f69645b44 to your computer and use it in GitHub Desktop.
A example of the kubernetes plugin with multiple build containers.
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
//Lets define a unique label for this build. | |
def label = "buildpod.${env.JOB_NAME}.${env.BUILD_NUMBER}".replace('-', '_').replace('/', '_') | |
//Lets create a new pod template with jnlp and maven containers, that uses that label. | |
podTemplate(label: label, containers: [ | |
containerTemplate(name: 'maven', image: 'maven', ttyEnabled: true, command: 'cat'), | |
containerTemplate(name: 'golang', image: 'golang:1.6.3-alpine', ttyEnabled: true, command: 'cat'), | |
containerTemplate(name: 'jnlp', image: 'jenkinsci/jnlp-slave:alpine', command: '/usr/local/bin/start.sh', args: '${computer.jnlpmac} ${computer.name}', ttyEnabled: false)], | |
volumes: [ | |
persistentVolumeClaim(mountPath: '/home/jenkins/.mvnrepo', claimName: 'jenkins-mvn-local-repo'), | |
secretVolume(mountPath: '/home/jenkins/.m2/', secretName: 'jenkins-maven-settings')]) { | |
//Lets use pod template (refernce by label) | |
node(label) { | |
git 'https://github.com/fabric8/kubernetes-model' | |
stage 'Genearate JSON schema' | |
container(name: 'golang') { | |
sh """ | |
go build -a ./cmd/generate/generate.go | |
./generate > kubernetes-model/src/main/resources/schema/kube-schema.json | |
""" | |
} | |
stage 'Build model from JSON schema' | |
container(name: 'maven') { | |
sh 'mvn clean install' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment