forked from jenkinsci/kubernetes-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile-kubernetes
70 lines (65 loc) · 1.79 KB
/
Jenkinsfile-kubernetes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* Build and test the kubernetes plugin using the plugin itself in a Kubernetes cluster
*
* A `jenkins` service account needs to be created using src/main/kubernetes/service-account.yml
*
* A PersistentVolumeClaim needs to be created ahead of time with the definition in examples/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
*/
def label = UUID.randomUUID().toString()
timestamps {
podTemplate(label: label, yaml: """
apiVersion: v1
kind: Pod
spec:
serviceAccountName: jenkins
containers:
- name: maven
command:
- cat
tty: true
env:
- name: MAVEN_OPTS
value: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
- name: BUILD_NUMBER
value: ${env.BUILD_NUMBER}
- name: BRANCH_NAME
value: ${env.BRANCH_NAME}
- name: _JAVA_OPTIONS
value: -Xmx300M
image: maven:3.5.4-jdk-8
resources:
limits:
memory: 1500Mi
requests:
cpu: 100m
memory: 1500Mi
""") {
node(label) {
stage('Checkout') {
checkout scm
}
stage('Package') {
try {
container('maven') {
sh 'mvn -B clean install -Dmaven.test.skip=true'
}
} finally {
archiveArtifacts allowEmptyArchive: true, artifacts: '**/target/*.hpi,**/target/*.jpi'
findbugs(includePattern:'**/target/findbugsXml.xml')
}
}
stage('Test') {
try {
container('maven') {
sh 'mvn -B test -DconnectorHost=0.0.0.0'
}
} finally {
junit '**/target/surefire-reports/**/*.xml'
}
}
}
}
}