forked from edureka-git/DevOpsClassCodes
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Jenkinsfile
58 lines (47 loc) · 1.57 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
#!/usr/bin/env groovy
import hudson.model.*
import hudson.EnvVars
import groovy.json.JsonSlurperClassic
import groovy.json.JsonBuilder
import groovy.json.JsonOutput
import java.net.URL
try {
node{
stage('Checkout') {
git 'https://github.com/edureka-git/DevOpsClassCodes'
}
stage('Build') {
dir('') {
sh 'mvn -B -V -U -e clean package'
}
}
stage ('Email') {
emailext attachLog: true, body: 'The status of the build can be obtained from the build log attached', subject: 'The build update is ', to: 'shubham.k@edureka.co'
}
stage('Deployment') {
// Deployment
script {
echo "deployment"
sh 'cp /var/lib/jenkins/workspace/package_1/target/addressbook.war /var/lib/tomcat8/webapps/'
}
}
stage('publish html report') {
echo "publishing the html report"
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: '', reportFiles: 'index.html', reportName: 'HTML Report', reportTitles: ''])
}
stage('clean up') {
echo "cleaning up the workspace"
cleanWs()
}
}// node
} // try end
finally {
(currentBuild.result != "ABORTED") && node("master") {
// Send e-mail notifications for failed or unstable builds.
// currentBuild.result must be non-null for this step to work.
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: 'shubham.k@edureka.co',
sendToIndividuals: true])
}
}