forked from javahometech/my-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
assignment
164 lines (153 loc) · 2.45 KB
/
assignment
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
160
161
162
163
164
def FAILED_STAGE
pipeline
{
tools
{
maven 'MAVEN_HOME'
jdk 'JAVA_HOME'
}
options
{
buildDiscarder(logRotator(numToKeepStr: '3', artifactNumToKeepStr: '3'))
}
agent
{
node
{
label ''
customWorkspace '/var/lib/jenkins/customworkspace'
}
}
stages
{
stage('code checkout')
{
steps
{
script
{
FAILED_STAGE=env.STAGE_NAME
properties([pipelineTriggers([githubPush()])])
}
git 'https://github.com/manyatripathi/my-app'
sh "mvn clean"
}
}
stage('compile')
{
steps
{
script
{
FAILED_STAGE=env.STAGE_NAME
}
sh "mvn compile"
}
}
stage('sonarqube analysis')
{
steps
{
script
{
FAILED_STAGE=env.STAGE_NAME
}
withSonarQubeEnv('sonar-1')
{
sh 'mvn sonar:sonar -Dsonar.host.url="http://52.172.195.61:9000"'
}
timeout(time: 10, unit: 'MINUTES')
{
waitForQualityGate abortPipeline: true
}
}
}
/*
stage('unit test')
{
steps
{
sh "mvn test"
junit 'target/surefire-reports/*.xml'
}
}
stage('code coverage')
{
steps
{
sh "mvn cobertura:cobertura"
step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'target/site/cobertura/coverage.xml', failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false])
}
}*/
/*
stage('performance and security')
{
parallel
{
stage('security testing')
{
steps
{
sh "mvn findbugs:findbugs"
}
}
stage('performance testing')
{
agent
{
label 'slave-1'
}
steps
{
sh "mvn verify"
}
}
}
}
*/
stage('war')
{
steps
{
script
{
FAILED_STAGE=env.STAGE_NAME
}
sh "mvn war:war"
}
}
/*stage('deploy to artifactory')
{
steps
{
sh "mvn deploy"
}
}
stage ('deploy to tomcat')
{
steps
{
sh "cp target/myweb-0.0.5.war /opt/tomcat/apache-tomcat-9.0.20/webapps"
}
}*/
/*
stage('integration testing')
{
steps
{
sh "mvn integration-test"
}
}
*/
}
post
{
always
{
deleteDir()
mail to: '[email protected]',
subject: "Status of pipeline: ${currentBuild.fullDisplayName}",
body: "${env.BUILD_URL} has result ${currentBuild.result} at stage ${FAILED_STAGE}"+e.toString()
}
}
}