forked from jenkinsci/kubernetes-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaven-with-cache.groovy
More file actions
24 lines (22 loc) · 899 Bytes
/
maven-with-cache.groovy
File metadata and controls
24 lines (22 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
* This pipeline will execute a simple maven build, using a Persistent Volume Claim to store the local Maven repository
*
* A PersistentVolumeClaim needs to be created ahead of time with the definition in maven-with-cache-pvc.yml
*
* NOTE that typically writable volumes can only be attached to one Pod at a time, so you can't execute
* two concurrent jobs with this pipeline. Or change readOnly: true after the first run
*/
podTemplate(containers: [
containerTemplate(name: 'maven', image: 'maven:3.8.1-jdk-8', command: 'sleep', args: '99d')
], volumes: [
persistentVolumeClaim(mountPath: '/root/.m2/repository', claimName: 'maven-repo', readOnly: false)
]) {
node(POD_LABEL) {
stage('Build a Maven project') {
git 'https://github.com/jenkinsci/kubernetes-plugin.git'
container('maven') {
sh 'mvn -B -ntp clean package -DskipTests'
}
}
}
}