Last active
November 7, 2016 12:59
-
-
Save iocanel/75af0acdef85ddf44122ed25cf43c1dd to your computer and use it in GitHub Desktop.
An example of the new kubernetes plugin pipeline capabilites
This file contains hidden or 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: '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/jenkinsci/kubernetes-plugin' | |
//Run shell commands in the 'maven' container... | |
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