-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gdsl
62 lines (56 loc) · 2.01 KB
/
build.gdsl
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
node {
commit_base_url = "https://github.com/Denis1990/testDummyRepository/commit/"
try {
stage("Clone") {
git credentialsId: '1df7eaef-1aa8-464f-96cd-1d3140d78817', url: '[email protected]:Denis1990/testDummyRepository.git'
}
stage("Build") {
timestamps {
withMaven(maven: 'mvn_3') {
sh "mvn compile"
}
}
}
stage("Test") {
timestamps {
withMaven(maven: 'mvn_3') {
sh "mvn test"
}
}
}
} catch(error) {
} finally {
// bodyTxt = '\nBuild job $JOB_BASE_NAME $BUILD_NUMBER completed in ${currentBuild.durationString}.\n\n\n${CHANGES_SINCE_LAST_SUCCESS}\n\n${GIT_REVISION}'
bodyTxt = constructChanges()
// TODO parametrize message based on build status
stage('Notify') {
emailext(
mimeType: "text/html",
attachLog: true,
compressLog: true,
body: bodyTxt,
subject: "$JOB_NAME - Build # $BUILD_NUMBER - $currentBuild.currentResult!",
to: '[email protected]'
)
}
}
}
@NonCPS
def constructChanges() {
def changeLogSets = currentBuild.changeSets
def msg ="Changes since last build.</br>"
for (int i = 0; i < changeLogSets.size(); i++) {
def entries = changeLogSets[i].items
for (int j = 0; j < entries.length; j++) {
def entry = entries[j]
msg += "Commit ${entry.commitId.substring(0,8)} by ${entry.author} on ${new Date(entry.timestamp)}: ${entry.msg} <a href='${commit_base_url + entry.commitId}'>github link</a></br>"
echo "$msg"
def files = new ArrayList(entry.affectedFiles)
for (int k = 0; k < files.size(); k++) {
def file = files[k]
echo " ${file.editType.name} ${file.path}"
}
}
}
return msg
}