-
Notifications
You must be signed in to change notification settings - Fork 0
/
JenkinsFile
81 lines (76 loc) · 2.18 KB
/
JenkinsFile
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
71
72
73
74
75
76
77
78
79
80
81
pipeline {
stage 'Clone the project'
git 'https://github.com/MuchChaca/expernet_spring.git'
dir('spring-jenkins-pipeline') {
stage("Compilation and Analysis") {
parallel 'Compilation': {
if (isUnix()) {
sh "./mvnw clean install -DskipTests"
} else {
bat "./mvnw.cmd clean install -DskipTests"
}
}, 'Static Analysis': {
stage("Checkstyle") {
if (isUnix()) {
sh "./mvnw checkstyle:checkstyle"
} else {
bat "./mvnw.cmd checkstyle:checkstyle"
}
step([$class: 'CheckStylePublisher',
canRunOnFailed: true,
defaultEncoding: '',
healthy: '100',
pattern: '**/target/checkstyle-result.xml',
unHealthy: '90',
useStableBuildAsReference: true
])
}
}
}
stage("Tests and Deployment") {
parallel 'Unit tests': {
stage("Running unit tests") {
try {
if (isUnix()) {
sh "./mvnw test -Punit"
} else {
bat "./mvnw.cmd test -Punit"
}
} catch(err) {
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*UnitTest.xml'])
throw err
}
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*UnitTest.xml'])
}
}, 'Integration tests': {
stage("Running integration tests") {
try {
if (isUnix()) {
sh "./mvnw test -Pintegration"
} else {
bat "./mvnw.cmd test -Pintegration"
}
} catch(err) {
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*IntegrationTest.xml'])
throw err
}
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*IntegrationTest.xml'])
}
}
stage("Staging") {
if (isUnix()) {
sh "pid=\$(lsof -i:9090 -t); kill -TERM \$pid || kill -KILL \$pid"
} else {
bat "FOR /F \"tokens=5 delims= \" %%G IN (\"netstat -a | findstr :9090\") DO TaskKill.exe /PID %%G /fi \"memusage gt 0\""
}
withEnv(['JENKINS_NODE_COOKIE=dontkill']) {
if (isUnix()) {
sh 'nohup ./mvnw spring-boot:run -Dserver.port=9090 &'
} else {
bat 'start ./mvnw.cmd spring-boot:run -Dserver.port=9090'
}
}
}
}
}
}