forked from LandmakTechnology/java-web-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsDeclarativePipelineScriptMarch2022
83 lines (76 loc) · 2.22 KB
/
JenkinsDeclarativePipelineScriptMarch2022
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
pipeline{
agent any
tools{
maven "maven3.8.4"
}
stages{
stage('1.clone'){
steps{
sh "echo clonning the latest version of the code"
git branch: 'feature', credentialsId: 'Git_Credentials', url: 'https://github.com/LandmakTechnology/paypal-web-app'
sh "echo clonning successful"
}
}
stage('2.Build'){
steps{
sh "echo validation, compilation, testing and package"
sh "echo testing successful and ready to package"
sh "mvn clean package"
}
}
stage('3.Quality'){
steps{
sh "echo performing code quality analysis"
sh "echo code quality successful and ready to upload"
sh "mvn sonar:sonar"
}
}
stage('4.uploadArtifacts'){
steps{
sh "mvn deploy"
}
}
stage('5.Deploy2UAT'){
steps{
sh "echo DEPLOYING TO UAT for further testing and validation"
sshagent(['agentcredentials']) {
sh "scp -o StrictHostKeyChecking=no target/*.war [email protected]:/opt/tomcat9/webapps/uatapp.war"
}
}
}
stage('6.Deploy2Prod'){
steps{
sh "echo DEPLOYING application TO Production"
timeout(time:8, unit:'HOURS'){
input message: 'Please approve deployment to Production'
}
sshagent(['agentcredentials']) {
sh "scp -o StrictHostKeyChecking=no target/*.war [email protected]:/opt/tomcat9/webapps/app.war"
}
}
}
}
post{
always{
mail bcc: '[email protected]', body: '''Success,
The build was great.
Regards
Landmark Technologies
+14372152483''', cc: '[email protected]', from: '', replyTo: '', subject: 'sucess', to: '[email protected]'
}
success{
mail bcc: '[email protected]', body: '''Success,
The build was great.
Regards
Landmark Technologies
+14372152483''', cc: '[email protected]', from: '', replyTo: '', subject: 'sucess', to: '[email protected]'
}
failure{
mail bcc: '[email protected]', body: '''Failed,
The build Failed.
Regards
Landmark Technologies
+14372152483''', cc: '[email protected]', from: '', replyTo: '', subject: 'Failed', to: '[email protected]'
}
}
}