This repository has been archived by the owner on Mar 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathJenkinsfile
49 lines (49 loc) · 1.77 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
pipeline {
agent any
stages {
stage('build') {
steps {
echo 'build stage'
withMaven(maven: '3.3.9') {
sh 'mvn formatter:validate'
}
}
}
stage('test') {
steps {
withMaven(maven: '3.3.9') {
sh 'mvn clean install -Pci'
}
}
}
}
post {
success {
echo 'success'
}
failure {
script {
def urlBase = "${env.GIT_URL}".replaceAll(/\.git/, "")
def commitUrl = urlBase + "/commit/${env.GIT_COMMIT}"
def commitsUrl = urlBase + "/commits/${env.GIT_BRANCH}"
def jenkinsUrl = "${env.BUILD_URL}".replaceAll(/\/\d+\//, "")
def commitMessage =
sh(
script: 'git shortlog ${GIT_COMMIT}^..${GIT_COMMIT}',
returnStdout: true
).trim()
commitMessage = commitMessage.replaceAll(/^[^\n]*\n\s*/,"")
emailext (
subject: "Source Code Issues Detected",
body: """<p>Source code issues detected in commit <a href='${commitUrl}'>${env.GIT_COMMIT}</a>:
<br/>
<strong>"${commitMessage}"</strong>.</p>
<p>View the issues in <a href='${commitsUrl}'>github</a>.</p>
<p>View the issues in <a href='${jenkinsUrl}'>jenkins</a>.</p>""",
mimeType: "text/html",
recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)
}
}
}
}