-
Notifications
You must be signed in to change notification settings - Fork 2
/
jenkinsFile
125 lines (104 loc) · 3.58 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
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
pipeline
{
agent any
stages{
stage("log") {
checkout scm
// commons = load("jenkinsfile-commons.groovy")
// commons.success()
}
stage('Checkout')
{
// Get CalibrationResults from GitHub
steps
{
// Get CombinationBuilder from GitHub
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'TeaLeafSaaS']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: '6463627-ab54-4e42-bc29-123458', url: 'https://github.com/manjushavnair/TeaLeafSaaS.git']]
])
script
{
echo getChangeString()
emailNotification( )
}
echo "mailer"
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: emailextrecipients([[$class: 'CulpritsRecipientProvider'],
[$class: 'RequesterRecipientProvider']])])
}//steps
}//stage
}//stages
}//piplein
//https://www.oreilly.com/library/view/jenkins-2-up/9781491979587/ch04.html
def emailNotification( ) {
def to = emailextrecipients([[$class: 'CulpritsRecipientProvider'],
[$class: 'DevelopersRecipientProvider'],
[$class: 'RequesterRecipientProvider'],
[$class: 'FailingTestSuspectsRecipientProvider'],
[$class: 'FirstFailingBuildSuspectsRecipientProvider'],
[$class: 'UpstreamComitterRecipientProvider']])
//committerEmail = bat (script: 'git --no-pager show -s --format='%ae'', returnStdout: true).trim()
//echo committerEmail
emailext (
to: 'kksclt@gmail.com',
// to: to,
attachLog: true,
compressLog: true,
// body: '''${SCRIPT, template="groovy_html.template"}''',
body: '''${JELLY_SCRIPT, template="html.jelly"}''',
mimeType: 'text/html',
replyTo: '$DEFAULT_REPLYTO',
subject: '${DEFAULT_SUBJECT}',
// recipients: emailextrecipients([[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']])]
recipientProviders: [[$class: 'CulpritsRecipientProvider'],
[$class: 'DevelopersRecipientProvider'],
[$class: 'RequesterRecipientProvider'],
[$class: 'FailingTestSuspectsRecipientProvider'],
[$class: 'FirstFailingBuildSuspectsRecipientProvider'],
[$class: 'UpstreamComitterRecipientProvider']]
)
}
@NonCPS
def getChangeString() {
MAX_MSG_LEN = 100
def changeString = ""
echo "Gathering SCM changes"
def changeLogSets = currentBuild.rawBuild.changeSets
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]
truncated_msg = entry.msg.take(MAX_MSG_LEN)
changeString += " - ${truncated_msg} [${entry.author}]\n"
}
}
if (!changeString) {
changeString = " - No new changes"
}
return changeString
}
@NonCPS // Necessary to allow .each to work.
def changelist() {
changeAuthors = currentBuild.changeSets.collect { set ->
set.collect { entry -> entry.author.fullName
echo entry.author.fullName
echo 'here'
}
}.flatten()
changeAuthors
/* def changes = ""
currentBuild.changeSets.each { set ->
set.each { entry ->
changes += "${entry.commitId} by ${entry.author.fullName}\n"
}
}
echo changes
changes
*/
}