-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
51 lines (47 loc) · 1.74 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
stage 'Compile & Test & Deploy'
node('master') {
checkout scm
try {
sh "mvn deploy"
} catch(e) {
currentBuild.result = "FAILED"
throw e
} finally {
notifyBuild(currentBuild.result)
}
stash 'working-copy'
step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile:"target/site/cobertura/coverage.xml", failNoReports: false, failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false])
}
stage 'Upload Sonar'
node('master') {
sh "mvn sonar:sonar"
unstash 'working-copy'
}
def notifyBuild(String buildStatus = 'STARTED') {
buildStatus = buildStatus ?: 'SUCCESS'
def colorName = 'RED'
def colorCode = '#FF0000'
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
def summary = "${subject} (${env.BUILD_URL})"
def details = """
<div style='font-family:微软雅黑'><p> Hi All:</p></div>
<div style='text-indent:35px;font-family:微软雅黑'><p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p></div>
<div style='text-indent:35px;font-family:微软雅黑'><p>Check console output at "<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p></div>
<div style='font-family:微软雅黑'><p>Thx</p></div>"""
if (buildStatus == 'STARTED') {
color = 'YELLOW'
colorCode = '#FFFF00'
} else if (buildStatus == 'SUCCESS') {
color = 'GREEN'
colorCode = '#00FF00'
} else {
color = 'RED'
colorCode = '#FF0000'
}
emailext (
subject: subject,
body: details,
to:'zhangjundongli@126.com',
recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)
}