Skip to content

Commit f11bfa0

Browse files
Create JenkinsfileDeclarativeNov2021
1 parent b1f7539 commit f11bfa0

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

JenkinsfileDeclarativeNov2021

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
pipeline{
2+
3+
agent any
4+
5+
6+
tools{
7+
maven 'maven3.8.4'
8+
}
9+
10+
triggers {
11+
pollSCM('* * * * *')
12+
//cron('* * * * *')
13+
}
14+
15+
options {
16+
//Add the Timestamp to the console output
17+
timestamps()
18+
//Discard Old Builds
19+
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '5', daysToKeepStr: '', numToKeepStr: '5')
20+
}
21+
stages{
22+
23+
//Get the code from GitHub
24+
stage('CheckoutCode'){
25+
steps{
26+
git branch: 'development', credentialsId: '87e4399d-5e09-4de8-b24d-926428729444', url: 'https://github.com/MithunTechnologiesDevOps/maven-web-application.git'
27+
}
28+
}
29+
30+
//Do the build
31+
stage('Build'){
32+
steps{
33+
sh "mvn clean package"
34+
}
35+
}
36+
37+
//Execute SonarQube Report
38+
stage('SonarQubeReport'){
39+
steps{
40+
sh "mvn clean sonar:sonar"
41+
}
42+
}
43+
44+
//Upload Artifact Into Nexus Server
45+
stage('UploadArtifactIntoNexusServer'){
46+
steps{
47+
sh "mvn clean deploy"
48+
}
49+
}
50+
51+
//Deploy App into Tomcat Server
52+
stage('DeployAppIntoTomcatServer'){
53+
steps{
54+
sshagent(['ff8e7c6e-91d1-46b7-a2ae-7b80841604c5']) {
55+
sh "scp -o StrictHostKeyChecking=no target/maven-web-application.war [email protected]:/opt/apache-tomcat-9.0.56/webapps/"
56+
}
57+
}
58+
}
59+
}//Stages Closing
60+
61+
post {
62+
always {
63+
emailext body: '''Build Over..
64+
65+
Regards,
66+
Mithun Technologies,
67+
9980923226''', subject: 'Build Over..', to: '[email protected]'
68+
}
69+
success {
70+
emailext body: '''Build Over.. Success
71+
72+
Regards,
73+
Mithun Technologies,
74+
9980923226''', subject: 'Build Over..', to: '[email protected]'
75+
}
76+
failure {
77+
emailext body: '''Build Over.. Failure
78+
79+
Regards,
80+
Mithun Technologies,
81+
9980923226''', subject: 'Build Over..', to: '[email protected]'
82+
}
83+
}
84+
85+
86+
}//Pipeline closing

0 commit comments

Comments
 (0)