Skip to content

Commit 729f1fe

Browse files
authored
Create JenkinsDeclarativePipelineScriptMarch2022
1 parent 48d189c commit 729f1fe

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
pipeline{
2+
agent any
3+
tools{
4+
maven "maven3.8.4"
5+
}
6+
stages{
7+
stage('1.clone'){
8+
steps{
9+
sh "echo clonning the latest version of the code"
10+
git branch: 'feature', credentialsId: 'Git_Credentials', url: 'https://github.com/LandmakTechnology/paypal-web-app'
11+
sh "echo clonning successful"
12+
}
13+
}
14+
stage('2.Build'){
15+
steps{
16+
sh "echo validation, compilation, testing and package"
17+
sh "echo testing successful and ready to package"
18+
sh "mvn clean package"
19+
}
20+
}
21+
stage('3.Quality'){
22+
steps{
23+
sh "echo performing code quality analysis"
24+
sh "echo code quality successful and ready to upload"
25+
sh "mvn sonar:sonar"
26+
}
27+
}
28+
stage('4.uploadArtifacts'){
29+
steps{
30+
sh "mvn deploy"
31+
}
32+
}
33+
stage('5.Deploy2UAT'){
34+
steps{
35+
sh "echo DEPLOYING TO UAT for further testing and validation"
36+
sshagent(['agentcredentials']) {
37+
sh "scp -o StrictHostKeyChecking=no target/*.war ec2-user@172.31.89.218:/opt/tomcat9/webapps/uatapp.war"
38+
}
39+
}
40+
}
41+
stage('6.Deploy2Prod'){
42+
steps{
43+
sh "echo DEPLOYING application TO Production"
44+
timeout(time:8, unit:'HOURS'){
45+
input message: 'Please approve deployment to Production'
46+
}
47+
sshagent(['agentcredentials']) {
48+
sh "scp -o StrictHostKeyChecking=no target/*.war ec2-user@172.31.89.218:/opt/tomcat9/webapps/app.war"
49+
}
50+
}
51+
}
52+
}
53+
post{
54+
always{
55+
mail bcc: 'mylandmarktech@gmail.com', body: '''Success,
56+
57+
The build was great.
58+
59+
Regards
60+
Landmark Technologies
61+
+14372152483''', cc: 'mylandmarktech@gmail.com', from: '', replyTo: '', subject: 'sucess', to: 'mylandmarktech@gmail.com'
62+
}
63+
success{
64+
mail bcc: 'mylandmarktech@gmail.com', body: '''Success,
65+
66+
The build was great.
67+
68+
Regards
69+
Landmark Technologies
70+
+14372152483''', cc: 'mylandmarktech@gmail.com', from: '', replyTo: '', subject: 'sucess', to: 'mylandmarktech@gmail.com'
71+
}
72+
failure{
73+
mail bcc: 'mylandmarktech@gmail.com', body: '''Failed,
74+
75+
The build Failed.
76+
77+
Regards
78+
Landmark Technologies
79+
+14372152483''', cc: 'mylandmarktech@gmail.com', from: '', replyTo: '', subject: 'Failed', to: 'mylandmarktech@gmail.com'
80+
}
81+
}
82+
83+
}

0 commit comments

Comments
 (0)