forked from jenkinsci/email-ext-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins-generic-matrix-email-html.template
414 lines (377 loc) · 10.4 KB
/
jenkins-generic-matrix-email-html.template
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
<title>${project.name}</title>
<STYLE>
body table, td, th, p, h1, h2 {
margin:0;
font:normal normal 100% Georgia, Serif;
background-color: #ffffff;
}
h1, h2 {
border-bottom:dotted 1px #999999;
padding:5px;
margin-top:10px;
margin-bottom:10px;
color: #000000;
font: normal bold 130% Georgia,Serif;
background-color:#f0f0f0;
}
tr.gray {
background-color:#f0f0f0;
}
h2 {
padding:5px;
margin-top:5px;
margin-bottom:5px;
font: italic bold 110% Georgia,Serif;
}
.bg2 {
color:black;
background-color:#E0E0E0;
font-size:110%
}
th {
font-weight: bold;
}
tr, td, th {
padding:2px;
}
td.test_passed {
color:blue;
}
td.test_failed {
color:red;
}
td.test_skipped {
color:grey;
}
.console {
font: normal normal 90% Courier New, monotype;
padding:0px;
margin:0px;
}
div.content, div.header {
background: #ffffff;
border: dotted
1px #666;
margin: 2px;
content: 2px;
padding: 2px;
}
table.border, th.border, td.border {
border: 1px solid black;
border-collapse:collapse;
}
</STYLE>
<BODY>
<%
import hudson.Util
import hudson.Functions
import hudson.model.Result;
import hudson.matrix.MatrixBuild
import hudson.matrix.MatrixRun
import hudson.matrix.MatrixConfiguration
import hudson.matrix.MatrixProject
import hudson.matrix.Combination
import hudson.matrix.Axis
if (build.result == Result.SUCCESS) {
result_img = "static/e59dfe28/images/32x32/blue.gif"
} else if (build.result == Result.FAILURE) {
result_img = "static/e59dfe28/images/32x32/red.gif"
} else {
result_img = "static/e59dfe28/images/32x32/yellow.gif"
}
if (build.builtOnStr == '') {
built_on = 'master'
} else {
built_on = build.builtOnStr
}
def healthIconSize = "16x16"
def healthReports = project.buildHealthReports
Integer total_builds = 0
Integer total_failed = 0
ArrayList<Map<String,hudson.model.Result>> status_array = new ArrayList<HashMap<String,hudson.model.Result>>();
ArrayList<Map<String,Integer>> total_builds_array = new ArrayList<HashMap<String,Integer>>();
ArrayList<Map<String,Integer>> total_failed_array = new ArrayList<HashMap<String,Integer>>();
hudson.matrix.MatrixProject matrix_project = project
def matrix_axis = matrix_project.getAxes()
def keys = []
for ( i = 0; i < matrix_axis.size(); i++ ){
def axis = matrix_axis.get(i);
keys << axis.getName();
status_array.add(new HashMap<String,hudson.model.Result>());
total_builds_array.add(new HashMap<String,Integer>());
total_failed_array.add(new HashMap<String,Integer>());
}
def matrix_build = build
def runs = matrix_build.getExactRuns();
ArrayList<hudson.matrix.Axis> axes = new ArrayList<hudson.matrix.Axis>();
for( i = 0; i < matrix_axis.size(); i++){
axes.add(matrix_axis.find(keys.get(i)));
}
String currentPropertyName
Boolean something_failed = false
// We want to initial all status maps to SUCCESS
// We use runs to get actual matrix values because matrix_axis keeps a record of all
// matrix/values. So, if you remove things they can still show up there.
for (hudson.matrix.MatrixRun run : runs) {
run_configuration = run.getParent()
configuration_combination = run_configuration.getCombination()
for( i = 0; i < axes.size(); i++){
currentPropertyName = configuration_combination.get(axes.get(i))
status_array.get(i).put(currentPropertyName,Result.SUCCESS)
total_builds_array.get(i).put(currentPropertyName,0)
total_failed_array.get(i).put(currentPropertyName,0)
}
total_builds = total_builds + 1
}
// OK, now run threw runs and set anything that FAILED.
for (hudson.matrix.MatrixRun run : runs) {
run_configuration = run.getParent()
configuration_combination = run_configuration.getCombination()
if (run.getResult() != Result.SUCCESS) {
total_failed = total_failed + 1
}
for( i = 0; i < axes.size(); i++){
currentPropertyName = configuration_combination.get(axes.get(i))
cnt = total_builds_array.get(i).get(currentPropertyName)
cnt = cnt + 1
total_builds_array.get(i).put(currentPropertyName,cnt)
if (run.getResult() != Result.SUCCESS) {
status_array.get(i).put(currentPropertyName,Result.FAILURE)
something_failed = true
cnt = total_failed_array.get(i).get(currentPropertyName)
cnt = cnt + 1
total_failed_array.get(i).put(currentPropertyName,cnt)
}
}
}
%>
<div class="header">
<!-- GENERAL INFO -->
<table>
<tr class="gray">
<td align="right">
<img src="${rooturl}${result_img}" />
</td>
<td valign="center">
<b style="font-size: 200%;">BUILD ${build.result}</b>
</td>
</tr>
<tr>
<td>Build URL</td>
<td>
<a href="${rooturl}${build.url}">${rooturl}${build.url}</a>
</td>
</tr>
<tr>
<td>Project:</td>
<td>${project.name}</td>
</tr>
<tr>
<td>Date of build:</td>
<td>${it.timestampString}</td>
</tr>
<tr>
<td>Build duration:</td>
<td>${build.durationString}</td>
</tr>
<tr>
<td>Build cause:</td>
<td>
<%
for (hudson.model.Cause cause : build.causes) {
%>
${cause.shortDescription}
<%
}
%>
</td>
</tr>
<%
if (build.description != null) {
%>
<tr>
<td>Build description:</td>
<td>${build.description}</td>
</tr>
<%
}
%>
<tr>
<td>Built on:</td>
<td>
${built_on}
</td>
</tr>
<tr>
<td>Total Builds:</td>
<td>
${total_builds}
</td>
</tr>
<%
if (total_failed != 0) {
%>
<tr>
<td>FAILURES:</td>
<td>
${total_failed} out of ${total_builds} builds FAILED!
</td>
</tr>
<%
}
%>
</tr>
</table>
</div>
<!-- HEALTH TEMPLATE -->
<div class="content">
<%
if (healthReports != null) {
%>
<h1>Health Report</h1>
<table>
<tr>
<th>W</th>
<th>Description</th>
<th>Score</th>
</tr>
<%
for (hudson.model.HealthReport healthReport : healthReports) {
__url = healthReport.getIconUrl(healthIconSize)
%>
<tr>
<td>
<img src="${rooturl}${__url}" />
</td>
<td>${healthReport.description}</td>
<td>${healthReport.score}</td>
</tr>
<%
}
%>
</table>
<br />
<%
}
%>
</div>
<!-- CHANGES TEMPLATE -->
<div class="content">
<%
if (build.changeSet != null) {
boolean hadChanges = false
hudson.scm.ChangeLogSet cs = build.getChangeSet()
%>
<a href="${rooturl}${build.url}/changes">
<h1>Changes</h1>
</a>
<%
for (hudson.scm.ChangeLogSet.Entry entry : cs) {
hadChanges = true
%>
<h2>${entry.msgAnnotated}</h2>
<p>by <em>${entry.author}</em></p>
<table>
<%
for (hudson.scm.ChangeLogSet.AffectedFile p : entry.affectedFiles) {
%>
<tr>
<td width="10%"> ${p.editType.name}</td>
<td>
<tt>${p.path}</tt>
</td>
</tr>
<%
}
%>
</table>
<%
}
if (hadChanges == false) {
%>
<p>No Changes</p>
<%
}
}
%>
</div>
<%
for( i = 0; i < axes.size(); i++){
%>
<div class="content">
<h1>${keys.get(i)} Summary</h1>
<table>
<%
for (String __val : status_array.get(i).keySet()) {
hudson.model.Result __result = status_array.get(i).get(__val)
Integer _total_cnt = total_builds_array.get(i).get(__val)
Integer _failed_cnt = total_failed_array.get(i).get(__val)
if (__result == Result.SUCCESS) {
%>
<TR><TD colspan="2" class="test_passed">${__val} - OK</TD></TR>
<%
} else {
%>
<TR><TD colspan="2" class="test_failed">${__val} - FAILED. ${_failed_cnt} out of ${_total_cnt} failed to build!</TD></TR>
<%
}
}
%>
</table>
</div>
<%
}
if (something_failed == true) {
%>
<div class="content">
<h1>Information</h1>
A change you committed to a source repository <b>MAY</b> be responsible for breaking a build.
<br>Review the data below or follow the link below to review the output of the build.
<br>If your change was responsible for the build failure, <b>fix ASAP</b>.
<br>If your change is not responsible, there is no need to respond to this email.
<br><b>All developers with changes</b> associated with this build failure will continue to be notified until the build succeeds.
<br><b>All developers that are notified</b> of a build failure will be informed by email when the build is once again successful.
<br>Instructions to reproduce the build failure will follow.
</div>
<div class="content">
<h1>Failed Builds</h1>
<%
for (hudson.matrix.MatrixRun run : runs) {
if (run.getResult() != Result.SUCCESS) {
String toolchain_val
run_configuration = run.getParent()
url = run.getUrl()
configuration_combination = run_configuration.getCombination()
%>
<div class="content">
<h2>Build Details</h2>
<table>
<tr>
<td>Build Output:</td>
<td style="word-break: break-all">
<a href="${rooturl}${url}/console">${rooturl}${url}console</a>
</td>
</tr>
<tr>
<td>Parameters:</td>
<td>
<%
for(i=0;i<axes.size();i++){
current_val = configuration_combination.get(axes.get(i))
%>
${keys.get(i)}=${current_val}
<%
}
%>
</td>
</tr>
</table>
</table>
</div>
<%
}
}
}
%>
</div>
</BODY>