forked from brahimhamdi/petclinic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkinsfile
160 lines (156 loc) · 5.4 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
pipeline {
agent {
label 'maven'
}
tools {
maven "M3"
}
stages {
stage('GitClone') {
steps {
script
{
//sh 'kill -9 `ps aux |grep petclinic | grep jar | awk {\'print $2\'}`'
git branch: 'main', url: 'https://github.com/brahimhamdi/petclinic'
}
}
}
stage('Build') {
steps {
script
{
if (isUnix())
{ sh 'rm -rf petclinic_test_plan.jtl'
sh 'mvn -fn clean package checkstyle:checkstyle pmd:pmd'
}
else
{
bat 'mvn -fn clean package checkstyle:checkstyle pmd:pmd'
}
}
}}
stage('QA Check & publish') {
steps {
script
{
recordIssues(tools: [checkStyle(), pmdParser()])
}
}
}
stage('Rapports de Tests') {
steps {
script
{
if (isUnix())
{
sh 'echo Rapports de tests'
}
else
{
bat 'echo Rapports de tests'
}
}
}
post {
success {
junit '**/target/surefire-reports/TEST-*.xml'
}
}
}
stage('Archivage artifacts') {
steps {
script
{
if (isUnix())
{
sh 'echo Archivage des artifacts'
}
else
{
bat 'echo Archivage des artifacts'
}
}
}
post {
success {
archiveArtifacts 'target/*.jar'
}
}
}
stage('deploy-petclinic-Test') {
steps {
script
{
if (isUnix())
{
sh 'scp target/spring-petclinic-3.0.0-SNAPSHOT.jar [email protected]:/tmp/'
sh 'ssh [email protected] java -jar /tmp/spring-petclinic-3.0.0-SNAPSHOT.jar &'
sh 'sleep 20'
}
else
{
bat 'scp target/spring-petclinic-3.0.0-SNAPSHOT.jar [email protected]:/tmp/'
bat 'ssh [email protected] java -jar /tmp/spring-petclinic-3.0.0-SNAPSHOT.jar &'
sh 'sleep 20'
}
}
}
}
stage('Test performance - Jmeter') {
steps {
script
{
if (isUnix())
{
sh 'scp petclinic_test_plan.jmx [email protected]:/tmp/'
sh 'ssh [email protected] "/opt/apache-jmeter-5.6.3/bin/jmeter -j jmeter.save.saveservice.output_format=xml -n -t /tmp/petclinic_test_plan.jmx -l /tmp/petclinic_test_plan.jtl"'
sh 'scp [email protected]:/tmp/petclinic_test_plan.jtl .'
}
else
{
bat 'scp petclinic_test_plan.jmx [email protected]:/tmp/'
bat 'ssh [email protected] "/opt/apache-jmeter-5.6.3/bin/jmeter -j jmeter.save.saveservice.output_format=xml -n -t /tmp/petclinic_test_plan.jmx -l /tmp/petclinic_test_plan.jtl"'
bat 'scp [email protected]:/tmp/petclinic_test_plan.jtl .'
}
}
}
post {
success {
perfReport errorFailedThreshold: 5, errorUnstableThreshold: 1, sourceDataFiles: 'petclinic_test_plan.jtl'
}
}
}
stage('Pub perf Test') {
steps {
script
{
sh 'echo publier rapport de test performance ################################################'
}
}
post {
success {
perfReport errorFailedThreshold: 5, errorUnstableThreshold: 1, sourceDataFiles: 'petclinic_test_plan.jtl'
}
}
}
stage('deploy-petclinic-Prod') {
steps {
script {
timeout(time: 30, unit: "MINUTES") {
input message: 'Voulez vous lancer le déploiement sur prod ?', ok: 'Yes'
}
if (isUnix())
{
sh 'scp target/spring-petclinic-3.0.0-SNAPSHOT.jar [email protected]:/tmp/'
sh 'ssh [email protected] java -jar /tmp/spring-petclinic-3.0.0-SNAPSHOT.jar &'
}
else
{
bat 'scp target/spring-petclinic-3.0.0-SNAPSHOT.jar [email protected]:/tmp/'
bat 'ssh [email protected] java -jar /tmp/spring-petclinic-3.0.0-SNAPSHOT.jar &'
}
}
}
}
}
}