Last active
August 7, 2018 18:20
-
-
Save iocanel/36d379bec5a96c70e7290c9c42bfa6b8 to your computer and use it in GitHub Desktop.
A example of the kubernetes plugin with multiple build containers.
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: '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' | |
} | |
} | |
} |
Is there way to declare multiple containerTemplate clauses with the DSL syntax?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@iocanel I just noticed from your blog post, the Github org is incorrect in the URL on line 15: fabric8 -> fabric8io