Commit | Line | Data |
---|---|---|
f3d8604b | 1 | /** |
073dc82c | 2 | * Copyright (C) 2016-2020 Michael Jeanson <mjeanson@efficios.com> |
f3d8604b MJ |
3 | * |
4 | * This program is free software: you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation, either version 3 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | */ | |
17 | ||
18 | import hudson.model.* | |
19 | import hudson.AbortException | |
20 | import hudson.console.HyperlinkNote | |
21 | import java.util.concurrent.CancellationException | |
22 | import org.eclipse.jgit.api.Git | |
23 | import org.eclipse.jgit.lib.Ref | |
24 | ||
25 | ||
3a01c580 MJ |
26 | class InvalidKVersionException extends Exception { |
27 | public InvalidKVersionException(String message) { | |
591756e5 MJ |
28 | super(message) |
29 | } | |
30 | } | |
31 | ||
3a01c580 MJ |
32 | class EmptyKVersionException extends Exception { |
33 | public EmptyKVersionException(String message) { | |
591756e5 MJ |
34 | super(message) |
35 | } | |
36 | } | |
37 | ||
3a01c580 | 38 | class VanillaKVersion implements Comparable<VanillaKVersion> { |
f3d8604b | 39 | |
3a01c580 MJ |
40 | Integer major = 0 |
41 | Integer majorB = 0 | |
42 | Integer minor = 0 | |
43 | Integer patch = 0 | |
44 | Integer rc = Integer.MAX_VALUE | |
f3d8604b | 45 | |
3a01c580 | 46 | VanillaKVersion() {} |
f3d8604b | 47 | |
3a01c580 | 48 | VanillaKVersion(version) { |
f3d8604b MJ |
49 | this.parse(version) |
50 | } | |
51 | ||
3a01c580 MJ |
52 | static VanillaKVersion minKVersion() { |
53 | return new VanillaKVersion("v0.0.0") | |
54 | } | |
55 | ||
56 | static VanillaKVersion maxKVersion() { | |
57 | return new VanillaKVersion("v" + Integer.MAX_VALUE + ".0.0") | |
58 | } | |
59 | ||
60 | static VanillaKVersion factory(version) { | |
61 | return new VanillaKVersion(version) | |
62 | } | |
63 | ||
f3d8604b MJ |
64 | def parse(version) { |
65 | this.major = 0 | |
66 | this.majorB = 0 | |
67 | this.minor = 0 | |
68 | this.patch = 0 | |
69 | this.rc = Integer.MAX_VALUE | |
70 | ||
591756e5 | 71 | if (!version) { |
3a01c580 | 72 | throw new EmptyKVersionException("Empty kernel version") |
591756e5 MJ |
73 | } |
74 | ||
f3d8604b MJ |
75 | def match = version =~ /^v(\d+)\.(\d+)(\.(\d+))?(\.(\d+))?(-rc(\d+))?$/ |
76 | if (!match) { | |
3a01c580 | 77 | throw new InvalidKVersionException("Invalid kernel version: ${version}") |
f3d8604b MJ |
78 | } |
79 | ||
80 | Integer offset = 0; | |
81 | ||
82 | // Major | |
83 | this.major = Integer.parseInt(match.group(1)) | |
84 | if (this.major <= 2) { | |
85 | offset = 2 | |
86 | this.majorB = Integer.parseInt(match.group(2)) | |
87 | } | |
88 | ||
89 | // Minor | |
90 | if (match.group(2 + offset) != null) { | |
91 | this.minor = Integer.parseInt(match.group(2 + offset)) | |
92 | } | |
93 | ||
94 | // Patch level | |
95 | if (match.group(4 + offset) != null) { | |
96 | this.patch = Integer.parseInt(match.group(4 + offset)) | |
97 | } | |
98 | ||
99 | // RC | |
100 | if (match.group(8) != null) { | |
101 | this.rc = Integer.parseInt(match.group(8)) | |
102 | } | |
103 | } | |
104 | ||
105 | // Return true if this version is a release candidate | |
106 | Boolean isRC() { | |
107 | return this.rc != Integer.MAX_VALUE | |
108 | } | |
109 | ||
e9b44189 | 110 | // Return true if both version are of the same stable branch |
3a01c580 | 111 | Boolean isSameStable(VanillaKVersion o) { |
e9b44189 MJ |
112 | if (this.major != o.major) { |
113 | return false | |
114 | } | |
115 | if (this.majorB != o.majorB) { | |
116 | return false | |
117 | } | |
118 | if (this.minor != o.minor) { | |
119 | return false | |
120 | } | |
121 | ||
122 | return true | |
123 | } | |
124 | ||
3a01c580 | 125 | @Override int compareTo(VanillaKVersion o) { |
f3d8604b | 126 | if (this.major != o.major) { |
e9b44189 | 127 | return Integer.compare(this.major, o.major) |
f3d8604b MJ |
128 | } |
129 | if (this.majorB != o.majorB) { | |
e9b44189 | 130 | return Integer.compare(this.majorB, o.majorB) |
f3d8604b MJ |
131 | } |
132 | if (this.minor != o.minor) { | |
e9b44189 | 133 | return Integer.compare(this.minor, o.minor) |
f3d8604b MJ |
134 | } |
135 | if (this.patch != o.patch) { | |
e9b44189 | 136 | return Integer.compare(this.patch, o.patch) |
f3d8604b MJ |
137 | } |
138 | if (this.rc != o.rc) { | |
e9b44189 | 139 | return Integer.compare(this.rc, o.rc) |
f3d8604b MJ |
140 | } |
141 | ||
142 | // Same version | |
143 | return 0; | |
144 | } | |
145 | ||
146 | String toString() { | |
147 | String vString = "v${this.major}" | |
148 | ||
149 | if (this.majorB > 0) { | |
150 | vString = vString.concat(".${this.majorB}") | |
151 | } | |
152 | ||
153 | vString = vString.concat(".${this.minor}") | |
154 | ||
155 | if (this.patch > 0) { | |
156 | vString = vString.concat(".${this.patch}") | |
157 | } | |
158 | ||
159 | if (this.rc > 0 && this.rc < Integer.MAX_VALUE) { | |
160 | vString = vString.concat("-rc${this.rc}") | |
161 | } | |
162 | return vString | |
163 | } | |
164 | } | |
165 | ||
4d8b6258 KS |
166 | class SlesKVersion implements Comparable<SlesKVersion> { |
167 | Integer major = 0 | |
168 | Integer minor = 0 | |
169 | Integer patch = 0 | |
170 | Integer slesrelease = 0 | |
171 | Integer slesmajor = 0 | |
172 | Integer slesminor = 0 | |
173 | ||
174 | SlesKVersion() {} | |
175 | ||
176 | SlesKVersion(version) { | |
177 | this.parse(version) | |
178 | } | |
179 | ||
180 | static SlesKVersion minKVersion() { | |
181 | return new SlesKVersion("rpm-0.0.0-0.0.0") | |
182 | } | |
183 | ||
184 | static SlesKVersion maxKVersion() { | |
185 | return new SlesKVersion("rpm-" + Integer.MAX_VALUE + ".0.0-0.0.0") | |
186 | } | |
187 | ||
188 | static SlesKVersion factory(version) { | |
189 | return new SlesKVersion(version) | |
190 | } | |
191 | ||
192 | def parse(version) { | |
193 | this.major = 0 | |
194 | this.minor = 0 | |
195 | this.patch = 0 | |
196 | this.slesrelease = 0 | |
197 | this.slesmajor = 0 | |
198 | this.slesminor = 0 | |
199 | ||
200 | if (!version) { | |
201 | throw new EmptyKVersionException("Empty kernel version") | |
202 | } | |
203 | ||
204 | // Eg. 5.14.21-150400.22 | |
205 | // Eg. 5.14.21-150400.24.100.2 | |
206 | // From tag: rpm-5.14.21-150400.24.100 -> 5.14.21-150400.24.100 | |
207 | def match = version =~ /^(rpm-)??(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)(\.\d+)??$/ | |
208 | if (!match) { | |
209 | throw new InvalidKVersionException("Invalid kernel version: ${version}") | |
210 | } | |
211 | ||
212 | this.major = Integer.parseInt(match.group(2)) | |
213 | this.minor = Integer.parseInt(match.group(3)) | |
214 | this.patch = Integer.parseInt(match.group(4)) | |
215 | this.slesrelease = Integer.parseInt(match.group(5)) | |
216 | this.slesmajor = Integer.parseInt(match.group(6)) | |
217 | ||
218 | if (match.group(7) != null) { | |
219 | this.slesminor = Integer.parseInt(match.group(7).drop(1)) | |
220 | } | |
221 | } | |
222 | ||
223 | Boolean isRC() { | |
224 | return false | |
225 | } | |
226 | ||
227 | Boolean isSameStable(SlesKVersion o) { | |
228 | if (this.major != o.major) { | |
229 | return false | |
230 | } | |
231 | if (this.minor != o.minor) { | |
232 | return false | |
233 | } | |
234 | if (this.patch != o.patch) { | |
235 | return false | |
236 | } | |
237 | if (this.slesrelease != o.slesrelease) { | |
238 | return false | |
239 | } | |
240 | if (this.slesmajor != o.slesmajor) { | |
241 | return false | |
242 | } | |
243 | if (this.slesminor != o.slesminor) { | |
244 | return false | |
245 | } | |
246 | return true | |
247 | } | |
248 | ||
249 | @Override int compareTo(SlesKVersion o) { | |
250 | if (this.major != o.major) { | |
251 | return Integer.compare(this.major, o.major) | |
252 | } | |
253 | if (this.minor != o.minor) { | |
254 | return Integer.compare(this.minor, o.minor) | |
255 | } | |
256 | if (this.patch != o.patch) { | |
257 | return Integer.compare(this.patch, o.patch) | |
258 | } | |
259 | if (this.slesrelease != o.slesrelease) { | |
260 | return Integer.compare(this.slesrelease, o.slesrelease) | |
261 | } | |
262 | if (this.slesmajor != o.slesmajor) { | |
263 | return Integer.compare(this.slesmajor, o.slesmajor) | |
264 | } | |
265 | if (this.slesminor != o.slesminor) { | |
266 | return Integer.compare(this.slesminor, o.slesminor) | |
267 | } | |
268 | return 0 | |
269 | } | |
270 | ||
271 | String toString() { | |
272 | String vString = "rpm-${this.major}.${this.minor}.${patch}-${this.slesrelease}.${this.slesmajor}" | |
273 | if (this.slesminor != 0) { | |
274 | vString = vString.concat(".${this.slesminor}") | |
275 | } | |
276 | return vString | |
277 | } | |
278 | } | |
279 | ||
3a01c580 MJ |
280 | class UbuntuKVersion implements Comparable<UbuntuKVersion> { |
281 | ||
282 | Integer major = 0 | |
283 | Integer minor = 0 | |
284 | Integer patch = 0 | |
285 | Integer umajor = 0 | |
286 | Integer uminor = 0 | |
287 | String suffix = "" | |
cba2f848 | 288 | String strLTS = "" |
3a01c580 MJ |
289 | Boolean isLTS = false |
290 | ||
291 | UbuntuKVersion() {} | |
292 | ||
293 | UbuntuKVersion(version) { | |
294 | this.parse(version) | |
295 | } | |
296 | ||
297 | static UbuntuKVersion minKVersion() { | |
298 | return new UbuntuKVersion("Ubuntu-lts-0.0.0-0.0") | |
299 | } | |
300 | ||
301 | static UbuntuKVersion maxKVersion() { | |
302 | return new UbuntuKVersion("Ubuntu-" + Integer.MAX_VALUE + ".0.0-0.0") | |
303 | } | |
304 | ||
305 | static UbuntuKVersion factory(version) { | |
306 | return new UbuntuKVersion(version) | |
307 | } | |
308 | ||
309 | def parse(version) { | |
310 | this.major = 0 | |
311 | this.minor = 0 | |
312 | this.patch = 0 | |
313 | this.umajor = 0 | |
314 | this.uminor = 0 | |
315 | this.suffix = ""; | |
316 | this.isLTS = false | |
317 | ||
318 | if (!version) { | |
319 | throw new EmptyKVersionException("Empty kernel version") | |
320 | } | |
321 | ||
073dc82c | 322 | //'Ubuntu-hwe-5.8-5.8.0-19.20_20.04.3', |
3a01c580 MJ |
323 | //'Ubuntu-lts-4.8.0-27.29_16.04.1', |
324 | //'Ubuntu-4.4.0-70.91', | |
073dc82c | 325 | def match = version =~ /^Ubuntu-(lts-|hwe-)??(?:\d+\.\d+-)??(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)(.*)??$/ |
3a01c580 MJ |
326 | if (!match) { |
327 | throw new InvalidKVersionException("Invalid kernel version: ${version}") | |
328 | } | |
329 | ||
cba2f848 MJ |
330 | if (match.group(1) != null) { |
331 | this.isLTS = true | |
332 | this.strLTS = match.group(1) | |
333 | } | |
3a01c580 MJ |
334 | |
335 | // Major | |
336 | this.major = Integer.parseInt(match.group(2)) | |
337 | ||
338 | // Minor | |
339 | this.minor = Integer.parseInt(match.group(3)) | |
340 | ||
341 | // Patch level | |
342 | this.patch = Integer.parseInt(match.group(4)) | |
343 | ||
344 | // Ubuntu major | |
345 | this.umajor = Integer.parseInt(match.group(5)) | |
346 | ||
347 | // Ubuntu minor | |
348 | this.uminor = Integer.parseInt(match.group(6)) | |
349 | ||
350 | if (match.group(7) != null) { | |
351 | this.suffix = match.group(7) | |
352 | } | |
353 | } | |
354 | ||
355 | // Return true if this version is a release candidate | |
356 | Boolean isRC() { | |
357 | return false | |
358 | } | |
359 | ||
360 | // Return true if both version are of the same stable branch | |
361 | Boolean isSameStable(UbuntuKVersion o) { | |
362 | if (this.isLTS != o.isLTS) { | |
363 | return false | |
364 | } | |
365 | if (this.major != o.major) { | |
366 | return false | |
367 | } | |
368 | if (this.minor != o.minor) { | |
369 | return false | |
370 | } | |
371 | if (this.patch != o.patch) { | |
372 | return false | |
373 | } | |
374 | ||
375 | return true | |
376 | } | |
377 | ||
378 | @Override int compareTo(UbuntuKVersion o) { | |
379 | if (this.major != o.major) { | |
380 | return Integer.compare(this.major, o.major) | |
381 | } | |
382 | if (this.minor != o.minor) { | |
383 | return Integer.compare(this.minor, o.minor) | |
384 | } | |
385 | if (this.patch != o.patch) { | |
386 | return Integer.compare(this.patch, o.patch) | |
387 | } | |
388 | if (this.umajor != o.umajor) { | |
389 | return Integer.compare(this.umajor, o.umajor) | |
390 | } | |
391 | if (this.uminor != o.uminor) { | |
392 | return Integer.compare(this.uminor, o.uminor) | |
393 | } | |
394 | if (this.isLTS != o.isLTS) { | |
395 | if (o.isLTS) { | |
396 | return 1 | |
397 | } else { | |
398 | return -1 | |
399 | } | |
400 | } | |
401 | ||
402 | // Same version | |
403 | return 0; | |
404 | } | |
405 | ||
406 | String toString() { | |
407 | String vString = "Ubuntu-" | |
408 | ||
409 | if (this.isLTS) { | |
cba2f848 | 410 | vString = vString.concat("${this.strLTS}") |
3a01c580 MJ |
411 | } |
412 | ||
46bde213 MJ |
413 | // The tag pattern changed for HWE kernels >= 5.0 |
414 | if (this.isLTS && this.major >= 5) { | |
073dc82c MJ |
415 | vString = vString.concat("${this.major}.${this.minor}-${this.major}.${this.minor}.${this.patch}-${this.umajor}.${this.uminor}${this.suffix}") |
416 | } else { | |
417 | vString = vString.concat("${this.major}.${this.minor}.${this.patch}-${this.umajor}.${this.uminor}${this.suffix}") | |
418 | } | |
3a01c580 MJ |
419 | |
420 | return vString | |
421 | } | |
422 | } | |
423 | ||
f3d8604b MJ |
424 | |
425 | // Retrieve parameters of the current build | |
28b10e79 | 426 | def mbranch = build.getEnvironment(listener).get('GIT_BRANCH').minus('origin/') |
f3d8604b MJ |
427 | def maxConcurrentBuild = build.buildVariableResolver.resolve('maxConcurrentBuild') |
428 | def kgitrepo = build.buildVariableResolver.resolve('kgitrepo') | |
591756e5 MJ |
429 | def kverfloor_raw = build.buildVariableResolver.resolve('kverfloor') |
430 | def kverceil_raw = build.buildVariableResolver.resolve('kverceil') | |
e9b44189 | 431 | def kverfilter = build.buildVariableResolver.resolve('kverfilter') |
28b10e79 | 432 | def kverrc = build.buildVariableResolver.resolve('kverrc') |
4d8b6258 | 433 | def slesversion = build.buildVariableResolver.resolve('slesversion') |
3a01c580 | 434 | def uversion = build.buildVariableResolver.resolve('uversion') |
f3d8604b | 435 | def job = Hudson.instance.getJob(build.buildVariableResolver.resolve('kbuildjob')) |
483859f3 | 436 | def currentJobName = build.project.getFullDisplayName() |
5a196804 | 437 | def gitmodpath = build.getEnvironment(listener).get('WORKSPACE') + "/src/lttng-modules" |
591756e5 | 438 | |
f3d8604b MJ |
439 | // Get the out variable |
440 | def config = new HashMap() | |
441 | def bindings = getBinding() | |
442 | config.putAll(bindings.getVariables()) | |
443 | def out = config['out'] | |
444 | ||
f3d8604b | 445 | |
5a196804 MJ |
446 | // Get the lttng-modules git url |
447 | def gitmodrepo = Git.open(new File(gitmodpath)) | |
448 | def mgitrepo = gitmodrepo.getRepository().getConfig().getString("remote", "origin", "url") | |
449 | ||
f3d8604b | 450 | // Get tags from git repository |
5a196804 | 451 | def refs = Git.lsRemoteRepository().setTags(true).setRemote(kgitrepo).call() |
f3d8604b MJ |
452 | |
453 | // Get kernel versions to build | |
454 | def kversions = [] | |
455 | def kversionsRC = [] | |
3a01c580 MJ |
456 | def matchStrs = [] |
457 | def blacklist = [] | |
458 | def kversionFactory = "" | |
459 | ||
4d8b6258 KS |
460 | if (slesversion != null) { |
461 | kversionFactory = new SlesKVersion() | |
462 | switch (slesversion) { | |
463 | case 'sles15sp4': | |
464 | matchStrs = [ | |
465 | ~/^refs\/tags\/(rpm-5.14.21-150400\.22(\.\d+)?(\.\d+)?)$/, | |
466 | ~/^refs\/tags\/(rpm-5.14.21-150400\.24(\.\d+)?(\.\d+)?)$/, | |
467 | ] | |
468 | blacklist = [ | |
469 | // "Retracted", @see https://www.suse.com/support/kb/doc/?id=000019587#SLE15SP4 | |
470 | 'rpm-5.14.21-150400.24.49', | |
471 | 'rpm-5.14.21-150400.24.84', | |
472 | ] | |
473 | break | |
474 | ||
475 | default: | |
476 | println "Unsupported SLES version: ${slesversion}" | |
477 | throw new InterruptedException() | |
478 | break | |
479 | } | |
480 | } else if (uversion != null) { | |
3a01c580 MJ |
481 | kversionFactory = new UbuntuKVersion() |
482 | switch (uversion) { | |
74901baa MJ |
483 | case 'jammy': |
484 | matchStrs = [ | |
485 | ~/^refs\/tags\/(Ubuntu-5\.15\.0-\d{1,3}?\.[\d]+)$/, | |
1af1b414 | 486 | ~/^refs\/tags\/(Ubuntu-hwe-6\.2-6\.2\.0-.*_22\.04\.\d+)$/, |
b6ebf05e | 487 | ~/^refs\/tags\/(Ubuntu-hwe-6\.5-6\.5\.0-.*_22\.04\.\d+)$/, |
74901baa MJ |
488 | ] |
489 | break | |
490 | ||
9e5757c6 MJ |
491 | case 'focal': |
492 | matchStrs = [ | |
493 | ~/^refs\/tags\/(Ubuntu-5\.4\.0-\d{1,3}?\.[\d]+)$/, | |
74901baa | 494 | ~/^refs\/tags\/(Ubuntu-hwe-5\.13-5\.13\.0-.*_20\.04\.\d+)$/, |
94ff4298 | 495 | ~/^refs\/tags\/(Ubuntu-hwe-5\.15-5\.15\.0-.*_20\.04\.\d+)$/, |
9e5757c6 MJ |
496 | ] |
497 | break | |
498 | ||
009efde7 KS |
499 | case 'noble': |
500 | matchStrs = [ | |
501 | ~/^refs\/tags\/(Ubuntu-6\.8\.0-\d{1,3}?\.[\d]+)$/, | |
502 | ] | |
503 | break | |
504 | ||
3a01c580 | 505 | default: |
57bdee9e | 506 | println "Unsupported Ubuntu version: ${uversion}" |
3a01c580 MJ |
507 | throw new InterruptedException() |
508 | break | |
509 | } | |
510 | } else { | |
511 | // Vanilla | |
512 | kversionFactory = new VanillaKVersion() | |
513 | matchStrs = [ | |
514 | ~/^refs\/tags\/(v[\d\.]+(-rc(\d+))?)$/, | |
515 | ] | |
2cfd47ab MJ |
516 | blacklist = [ |
517 | 'v3.2.3', | |
518 | ] | |
3a01c580 | 519 | } |
f3d8604b | 520 | |
3a01c580 MJ |
521 | // Parse kernel versions |
522 | def kverfloor = "" | |
523 | try { | |
524 | kverfloor = kversionFactory.factory(kverfloor_raw) | |
525 | } catch (EmptyKVersionException e) { | |
526 | kverfloor = kversionFactory.minKVersion() | |
527 | } | |
f3d8604b | 528 | |
3a01c580 MJ |
529 | def kverceil = "" |
530 | try { | |
531 | kverceil = kversionFactory.factory(kverceil_raw) | |
532 | } catch (EmptyKVersionException e) { | |
533 | kverceil = kversionFactory.maxKVersion() | |
534 | } | |
535 | ||
536 | // Build a sorted list of versions to build | |
537 | for (ref in refs) { | |
538 | for (matchStr in matchStrs) { | |
539 | def match = ref.getName() =~ matchStr | |
540 | if (match && !blacklist.contains(match.group(1))) { | |
541 | def v = kversionFactory.factory(match.group(1)) | |
542 | ||
543 | if ((v >= kverfloor) && (v < kverceil)) { | |
544 | if (v.isRC()) { | |
545 | kversionsRC.add(v) | |
546 | } else { | |
547 | kversions.add(v) | |
548 | } | |
f3d8604b MJ |
549 | } |
550 | } | |
551 | } | |
552 | } | |
553 | ||
cff1edbb | 554 | // The filtering step assumes the version lists are sorted |
f3d8604b MJ |
555 | kversions.sort() |
556 | kversionsRC.sort() | |
557 | ||
e9b44189 MJ |
558 | switch (kverfilter) { |
559 | case 'stable-head': | |
560 | // Keep only the head of each stable branch | |
561 | println('Filter kernel versions to keep only the latest point release of each stable branch.') | |
562 | ||
563 | for (i = 0; i < kversions.size(); i++) { | |
564 | def curr = kversions[i] | |
565 | def next = i < kversions.size() - 1 ? kversions[i + 1] : null | |
566 | ||
567 | if (next != null) { | |
568 | if (curr.isSameStable(next)) { | |
569 | kversions.remove(i) | |
570 | i-- | |
571 | } | |
572 | } | |
573 | } | |
574 | break | |
575 | ||
3da11679 | 576 | case 'lts-head': |
cff1edbb MJ |
577 | // Keep only the head of each LTS branch and the latest non-RC tag |
578 | println('Filter kernel versions to keep only the latest point release of each lts branch and the current stable.') | |
579 | ||
3da11679 | 580 | def lts_kversions = [] |
242e40f0 KS |
581 | // Old LTS entries are kept so that "lts-head" is still meaningful in kernel |
582 | // version ranges that are supported by lttng-modules but no longer supported | |
583 | // upstream, eg. lttng-modules stable-2.13 supports >= 3.0 | |
584 | lts_kversions.add(kversionFactory.factory("v3.0")) // LTS until October 2013 | |
585 | lts_kversions.add(kversionFactory.factory("v3.2")) // LTS until May 2018 | |
586 | lts_kversions.add(kversionFactory.factory("v3.4")) // LTS until October 2016 | |
587 | lts_kversions.add(kversionFactory.factory("v3.10")) // LTS until November 2017 | |
588 | lts_kversions.add(kversionFactory.factory("v3.12")) // LTS until May 2017 | |
589 | lts_kversions.add(kversionFactory.factory("v3.14")) // LTS until August 2016 | |
590 | lts_kversions.add(kversionFactory.factory("v3.16")) // LTS until October 2014 | |
591 | lts_kversions.add(kversionFactory.factory("v3.18")) // LTS until January 2017 | |
592 | lts_kversions.add(kversionFactory.factory("v4.1")) // LTS until May 2018 | |
3da11679 MJ |
593 | lts_kversions.add(kversionFactory.factory("v4.4")) // SLTS until 2026 |
594 | lts_kversions.add(kversionFactory.factory("v4.9")) // LTS until January 2023 | |
595 | lts_kversions.add(kversionFactory.factory("v4.14")) // LTS until January 2024 | |
596 | lts_kversions.add(kversionFactory.factory("v4.19")) // LTS until December 2024 | |
597 | lts_kversions.add(kversionFactory.factory("v5.4")) // LTS until December 2025 | |
598 | lts_kversions.add(kversionFactory.factory("v5.10")) // LTS until December 2026 | |
6ab31912 | 599 | lts_kversions.add(kversionFactory.factory("v5.15")) // LTS until December 2026 |
3da11679 | 600 | lts_kversions.add(kversionFactory.factory("v6.1")) // LTS until December 2026 |
6ab31912 | 601 | lts_kversions.add(kversionFactory.factory("v6.6")) // LTS until December 2026 |
cff1edbb MJ |
602 | |
603 | // First filter the head of each branch | |
604 | for (i = 0; i < kversions.size(); i++) { | |
605 | def curr = kversions[i] | |
606 | def next = i < kversions.size() - 1 ? kversions[i + 1] : null | |
607 | ||
608 | if (next != null) { | |
609 | if (curr.isSameStable(next)) { | |
610 | kversions.remove(i) | |
611 | i-- | |
612 | } | |
613 | } | |
614 | } | |
615 | ||
616 | for (i = 0; i < kversions.size(); i++) { | |
617 | def curr = kversions[i] | |
618 | ||
619 | // Keep the newest tag | |
620 | if (i == kversions.size() - 1) { | |
621 | break | |
622 | } | |
623 | ||
624 | // Prune non-LTS versions | |
3da11679 MJ |
625 | def keep = false |
626 | for (j = 0; j < lts_kversions.size(); j++) { | |
627 | if (curr.isSameStable(lts_kversions[j])) { | |
628 | keep = true | |
629 | break | |
630 | } | |
631 | } | |
632 | ||
633 | if (!keep) { | |
cff1edbb MJ |
634 | kversions.remove(i) |
635 | i-- | |
636 | } | |
637 | } | |
638 | break | |
639 | ||
e9b44189 MJ |
640 | default: |
641 | // No filtering of kernel versions | |
642 | println('No kernel versions filtering selected.') | |
643 | break | |
644 | } | |
645 | ||
28b10e79 MJ |
646 | if (kverrc == "true") { |
647 | // If the last RC version is newer than the last stable, add it to the build list | |
648 | if (kversionsRC.size() > 0 && kversionsRC.last() > kversions.last()) { | |
649 | kversions.add(kversionsRC.last()) | |
650 | } | |
f3d8604b MJ |
651 | } |
652 | ||
f3d8604b MJ |
653 | println "Building the following kernel versions:" |
654 | for (k in kversions) { | |
655 | println k | |
656 | } | |
657 | ||
658 | // Debug: Stop build here | |
659 | //throw new InterruptedException() | |
660 | ||
661 | def joburl = HyperlinkNote.encodeTo('/' + job.url, job.fullDisplayName) | |
662 | ||
663 | def allBuilds = [] | |
664 | def ongoingBuild = [] | |
665 | def failedRuns = [] | |
666 | def isFailed = false | |
483859f3 | 667 | def similarJobQueued = 0; |
f3d8604b MJ |
668 | |
669 | // Loop while we have kernel versions remaining or jobs running | |
670 | while ( kversions.size() != 0 || ongoingBuild.size() != 0 ) { | |
671 | ||
672 | if(ongoingBuild.size() < maxConcurrentBuild.toInteger() && kversions.size() != 0) { | |
673 | def kversion = kversions.pop() | |
674 | def job_params = [ | |
28b10e79 | 675 | new StringParameterValue('mversion', mbranch), |
5a196804 | 676 | new StringParameterValue('mgitrepo', mgitrepo), |
a1ae361e | 677 | new StringParameterValue('ktag', kversion.toString()), |
f3d8604b MJ |
678 | new StringParameterValue('kgitrepo', kgitrepo), |
679 | ] | |
680 | ||
681 | // Launch the parametrized build | |
682 | def param_build = job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(job_params)) | |
28b10e79 | 683 | println "triggering ${joburl} for the ${mbranch} branch on kernel ${kversion}" |
f3d8604b MJ |
684 | |
685 | // Add it to the ongoing build queue | |
686 | ongoingBuild.push(param_build) | |
687 | ||
688 | } else { | |
689 | ||
690 | println "Waiting... Queued: " + kversions.size() + " Running: " + ongoingBuild.size() | |
691 | try { | |
3a01c580 | 692 | Thread.sleep(10000) |
f3d8604b MJ |
693 | } catch(e) { |
694 | if (e in InterruptedException) { | |
695 | build.setResult(hudson.model.Result.ABORTED) | |
696 | throw new InterruptedException() | |
697 | } else { | |
698 | throw(e) | |
699 | } | |
700 | } | |
701 | ||
3a01c580 | 702 | // Abort job if a newer instance is queued |
b7efa3aa MJ |
703 | if (!currentJobName.contains("gerrit")) { |
704 | similarJobQueued = Hudson.instance.queue.items.count{it.task.getFullDisplayName() == currentJobName} | |
705 | if (similarJobQueued > 0) { | |
706 | println "Abort, a newer instance of the job was queued" | |
483859f3 JR |
707 | build.setResult(hudson.model.Result.ABORTED) |
708 | throw new InterruptedException() | |
b7efa3aa | 709 | } |
483859f3 JR |
710 | } |
711 | ||
f3d8604b MJ |
712 | def i = ongoingBuild.iterator() |
713 | while ( i.hasNext() ) { | |
714 | currentBuild = i.next() | |
715 | if ( currentBuild.isCancelled() || currentBuild.isDone() ) { | |
716 | // Remove from queue | |
717 | i.remove() | |
718 | ||
719 | // Print results | |
720 | def matrixParent = currentBuild.get() | |
721 | allBuilds.add(matrixParent) | |
a1ae361e | 722 | def kernelStr = matrixParent.buildVariableResolver.resolve("ktag") |
f3d8604b MJ |
723 | println "${matrixParent.fullDisplayName} (${kernelStr}) completed with status ${matrixParent.result}" |
724 | ||
725 | // Process child runs of matrixBuild | |
726 | def childRuns = matrixParent.getRuns() | |
727 | for ( childRun in childRuns ) { | |
728 | println "\t${childRun.fullDisplayName} (${kernelStr}) completed with status ${childRun.result}" | |
729 | if (childRun.result != Result.SUCCESS) { | |
730 | failedRuns.add(childRun) | |
731 | isFailed = true | |
732 | } | |
733 | } | |
734 | } | |
735 | } | |
736 | } | |
737 | } | |
738 | ||
739 | // Get log of failed runs | |
740 | for (failedRun in failedRuns) { | |
741 | println "---START---" | |
742 | failedRun.writeWholeLogTo(out) | |
743 | println "---END---" | |
744 | } | |
745 | ||
746 | println "---Build report---" | |
747 | for (b in allBuilds) { | |
a1ae361e | 748 | def kernelStr = b.buildVariableResolver.resolve("ktag") |
f3d8604b | 749 | println "${b.fullDisplayName} (${kernelStr}) completed with status ${b.result}" |
7e02032c | 750 | // Cleanup builds |
7e942863 MJ |
751 | try { |
752 | b.delete() | |
753 | } catch (all) {} | |
f3d8604b MJ |
754 | } |
755 | ||
756 | // Mark this build failed if any child build has failed | |
757 | if (isFailed) { | |
c5c05f73 | 758 | build.setResult(hudson.model.Result.FAILURE) |
f3d8604b MJ |
759 | } |
760 | ||
761 | // EOF |