@@ -31,38 +31,48 @@ node {
3131
3232 stage("Tests and Deployment") {
3333 parallel 'Unit tests': {
34- stage("Runing unit tests") {
35- if (isUnix()) {
36- sh "./mvnw test -Punit"
37- } else {
38- bat "./mvnw.cmd test -Punit"
34+ stage("Running unit tests") {
35+ try {
36+ if (isUnix()) {
37+ sh "./mvnw test -Punit"
38+ } else {
39+ bat "./mvnw.cmd test -Punit"
40+ }
41+ } catch(err) {
42+ step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*UnitTest.xml'])
43+ throw err
3944 }
4045 step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*UnitTest.xml'])
4146
4247 }
4348 }, 'Integration tests': {
44- stage("Runing integration tests") {
45- if (isUnix()) {
46- sh "./mvnw test -Pintegration"
47- } else {
48- bat "./mvnw.cmd test -Pintegration"
49+ stage("Running integration tests") {
50+ try {
51+ if (isUnix()) {
52+ sh "./mvnw test -Pintegration"
53+ } else {
54+ bat "./mvnw.cmd test -Pintegration"
55+ }
56+ } catch(err) {
57+ step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*IntegrationTest.xml'])
58+ throw err
4959 }
5060 step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*IntegrationTest.xml'])
5161 }
52- }, 'Deployment': {
53- stage("Staging") {
62+ }
63+
64+ stage("Staging") {
65+ if (isUnix()) {
66+ sh "pid=\$(lsof -i:8989 -t); kill -TERM \$pid || kill -KILL \$pid"
67+ } else {
68+ bat "FOR /F \"tokens=5 delims= \" %%G IN (\"netstat -a | findstr :8989\") DO TaskKill.exe /PID %%G /fi \"memusage gt 0\""
69+ }
70+
71+ withEnv(['JENKINS_NODE_COOKIE=dontkill']) {
5472 if (isUnix()) {
55- sh "pid=\$(lsof -i:8989 -t); kill -TERM \$pid || kill -KILL \$pid"
73+ sh 'nohup ./mvnw spring-boot:run -Dserver.port=8989 &'
5674 } else {
57- bat "FOR /F \"tokens=5 delims= \" %%G IN (\"netstat -a | findstr :8989\") DO TaskKill.exe /PID %%G /fi \"memusage gt 0\""
58- }
59-
60- withEnv(['JENKINS_NODE_COOKIE=dontkill']) {
61- if (isUnix()) {
62- sh 'nohup ./mvnw spring-boot:run -Dserver.port=8989 &'
63- } else {
64- bat 'start ./mvnw.cmd spring-boot:run -Dserver.port=8989'
65- }
75+ bat 'start ./mvnw.cmd spring-boot:run -Dserver.port=8989'
6676 }
6777 }
6878 }
0 commit comments