forked from jenkinsci/kubernetes-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-kubernetes
62 lines (60 loc) · 1.61 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
/**
* 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
*/
podTemplate(yaml: """
apiVersion: v1
kind: Pod
spec:
serviceAccountName: jenkins
containers:
- name: maven
command:
- cat
tty: true
env:
- name: BUILD_NUMBER
value: ${env.BUILD_NUMBER}
- name: BRANCH_NAME
value: ${env.BRANCH_NAME}
- name: _JAVA_OPTIONS
value: -Xmx300M
image: maven:3.6.1-jdk-8
resources:
limits:
memory: 1500Mi
requests:
cpu: 100m
memory: 1500Mi
""") {
node(POD_LABEL) {
stage('Checkout') {
checkout scm
}
stage('Package') {
try {
container('maven') {
sh 'mvn -B -ntp 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 -ntp test -DconnectorHost=0.0.0.0'
}
} finally {
junit '**/target/surefire-reports/**/*.xml'
}
}
}
}