-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfileWorking
More file actions
61 lines (55 loc) · 1.62 KB
/
JenkinsfileWorking
File metadata and controls
61 lines (55 loc) · 1.62 KB
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
pipeline {
agent {
docker {
image 'docker:20.10.7-dind'
image 'maven:3.9.8-eclipse-temurin-21'
args '--privileged -v /var/run/docker.sock:/var/run/docker.sock'
}
}
tools{
maven 'maven'
}
environment {
SONAR_TOKEN = credentials('SONAR_TOKEN')
}
stages {
stage('Checkout') {
steps {
git branch: 'main', url: 'https://github.com/mekaizen/sdtest.git'
}
}
stage('Build') {
steps {
sh 'mvn clean package'
}
}
stage('Test') {
steps {
sh 'mvn test'
}
}
}
post {
success {
echo 'Build, test, and ZAP scan passed'
}
failure {
echo 'Build failed'
}
always {
script {
sh '''
# docker container prune -f
# Check if the process exists before killing
pid=$(ps aux | grep 'sdlc-test.jar' | grep -v 'grep' | awk '{print $2}')
if [ -n "$pid" ]; then
kill $pid
else
echo "Process not found, skipping kill."
fi
# kill $(ps aux | grep 'sdlc-test.jar' | awk '{print $2}')
'''
}
}
}
}