/**
- * Copyright (C) 2016-2017 - Michael Jeanson <mjeanson@efficios.com>
+ * Copyright (C) 2016-2020 Michael Jeanson <mjeanson@efficios.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Integer umajor = 0
Integer uminor = 0
String suffix = ""
+ String strLTS = ""
Boolean isLTS = false
UbuntuKVersion() {}
throw new EmptyKVersionException("Empty kernel version")
}
+ //'Ubuntu-hwe-5.8-5.8.0-19.20_20.04.3',
//'Ubuntu-lts-4.8.0-27.29_16.04.1',
//'Ubuntu-4.4.0-70.91',
- def match = version =~ /^Ubuntu-(lts-)??(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)(.*)??$/
+ def match = version =~ /^Ubuntu-(lts-|hwe-)??(?:\d+\.\d+-)??(\d+)\.(\d+)\.(\d+)-(\d+)\.(\d+)(.*)??$/
if (!match) {
throw new InvalidKVersionException("Invalid kernel version: ${version}")
}
- this.isLTS = match.group(1) != null
+ if (match.group(1) != null) {
+ this.isLTS = true
+ this.strLTS = match.group(1)
+ }
// Major
this.major = Integer.parseInt(match.group(2))
String vString = "Ubuntu-"
if (this.isLTS) {
- vString = vString.concat("lts-")
+ vString = vString.concat("${this.strLTS}")
}
- vString = vString.concat("${this.major}.${this.minor}.${this.patch}-${this.umajor}.${this.uminor}${this.suffix}")
+ // The tag pattern changed for HWE kernels >= 5.0
+ if (this.isLTS && this.major >= 5) {
+ vString = vString.concat("${this.major}.${this.minor}-${this.major}.${this.minor}.${this.patch}-${this.umajor}.${this.uminor}${this.suffix}")
+ } else {
+ vString = vString.concat("${this.major}.${this.minor}.${this.patch}-${this.umajor}.${this.uminor}${this.suffix}")
+ }
return vString
}
// Retrieve parameters of the current build
-def mversion = build.buildVariableResolver.resolve('mversion')
+def mbranch = build.getEnvironment(listener).get('GIT_BRANCH').minus('origin/')
def maxConcurrentBuild = build.buildVariableResolver.resolve('maxConcurrentBuild')
def kgitrepo = build.buildVariableResolver.resolve('kgitrepo')
def kverfloor_raw = build.buildVariableResolver.resolve('kverfloor')
def kverceil_raw = build.buildVariableResolver.resolve('kverceil')
def kverfilter = build.buildVariableResolver.resolve('kverfilter')
+def kverrc = build.buildVariableResolver.resolve('kverrc')
def uversion = build.buildVariableResolver.resolve('uversion')
def job = Hudson.instance.getJob(build.buildVariableResolver.resolve('kbuildjob'))
def currentJobName = build.project.getFullDisplayName()
-
+def gitmodpath = build.getEnvironment(listener).get('WORKSPACE') + "/src/lttng-modules"
// Get the out variable
def config = new HashMap()
def out = config['out']
+// Get the lttng-modules git url
+def gitmodrepo = Git.open(new File(gitmodpath))
+def mgitrepo = gitmodrepo.getRepository().getConfig().getString("remote", "origin", "url")
+
// Get tags from git repository
-def refs = Git.lsRemoteRepository().setTags(true).setRemote(kgitrepo).call();
+def refs = Git.lsRemoteRepository().setTags(true).setRemote(kgitrepo).call()
// Get kernel versions to build
def kversions = []
if (uversion != null) {
kversionFactory = new UbuntuKVersion()
switch (uversion) {
- case 'xenial':
+ case 'focal':
matchStrs = [
- ~/^refs\/tags\/(Ubuntu-4\.4\.0-\d{1,3}?\.[\d]+)$/,
- ~/^refs\/tags\/(Ubuntu-lts-4\.8\.0-.*_16\.04\.\d+)$/,
- ~/^refs\/tags\/(Ubuntu-lts-4\.10\.0-.*_16\.04\.\d+)$/,
+ ~/^refs\/tags\/(Ubuntu-5\.4\.0-\d{1,3}?\.[\d]+)$/,
+ ~/^refs\/tags\/(Ubuntu-hwe-5\.8-5\.8\.0-.*_20\.04\.\d+)$/,
]
+ break
- blacklist = [
- 'Ubuntu-lts-4.10.0-7.9_16.04.1',
+ case 'bionic':
+ matchStrs = [
+ ~/^refs\/tags\/(Ubuntu-4\.15\.0-\d{1,3}?\.[\d]+)$/,
+ ~/^refs\/tags\/(Ubuntu-hwe-5\.0-5\.0\.0-.*_18\.04\.\d+)$/,
+ ~/^refs\/tags\/(Ubuntu-hwe-5\.4-5\.4\.0-.*_18\.04\.\d+)$/,
]
break
- case 'trusty':
+ case 'xenial':
matchStrs = [
- ~/^refs\/tags\/(Ubuntu-3\.13\.0-[\d\.]+)$/,
- ~/^refs\/tags\/(Ubuntu-lts-.*_14\.04\.\d+)$/,
+ ~/^refs\/tags\/(Ubuntu-4\.4\.0-\d{1,3}?\.[\d]+)$/,
+ ~/^refs\/tags\/(Ubuntu-hwe-4\.15\.0-.*_16\.04\.\d+)$/,
]
break
default:
- println 'Unsupported Ubuntu version: ${uversion}'
+ println "Unsupported Ubuntu version: ${uversion}"
throw new InterruptedException()
break
}
matchStrs = [
~/^refs\/tags\/(v[\d\.]+(-rc(\d+))?)$/,
]
+ blacklist = [
+ 'v3.2.3',
+ ]
}
// Parse kernel versions
}
}
+// The filtering step assumes the version lists are sorted
kversions.sort()
kversionsRC.sort()
}
break
+ case 'lts':
+ // Keep only the head of each LTS branch and the latest non-RC tag
+ println('Filter kernel versions to keep only the latest point release of each lts branch and the current stable.')
+
+ def lts_44 = kversionFactory.factory("v4.4")
+ def lts_49 = kversionFactory.factory("v4.9")
+ def lts_414 = kversionFactory.factory("v4.14")
+ def lts_419 = kversionFactory.factory("v4.19")
+ def lts_54 = kversionFactory.factory("v5.4")
+
+ // First filter the head of each branch
+ for (i = 0; i < kversions.size(); i++) {
+ def curr = kversions[i]
+ def next = i < kversions.size() - 1 ? kversions[i + 1] : null
+
+ if (next != null) {
+ if (curr.isSameStable(next)) {
+ kversions.remove(i)
+ i--
+ }
+ }
+ }
+
+ for (i = 0; i < kversions.size(); i++) {
+ def curr = kversions[i]
+
+ // Keep the newest tag
+ if (i == kversions.size() - 1) {
+ break
+ }
+
+ // Prune non-LTS versions
+ if (!(curr.isSameStable(lts_44) || curr.isSameStable(lts_49) || curr.isSameStable(lts_414) || curr.isSameStable(lts_419) || curr.isSameStable(lts_54))) {
+ kversions.remove(i)
+ i--
+ }
+ }
+ break
+
default:
// No filtering of kernel versions
println('No kernel versions filtering selected.')
break
}
-// If the last RC version is newer than the last stable, add it to the build list
-if (kversionsRC.size() > 0 && kversionsRC.last() > kversions.last()) {
- kversions.add(kversionsRC.last())
+if (kverrc == "true") {
+ // If the last RC version is newer than the last stable, add it to the build list
+ if (kversionsRC.size() > 0 && kversionsRC.last() > kversions.last()) {
+ kversions.add(kversionsRC.last())
+ }
}
println "Building the following kernel versions:"
if(ongoingBuild.size() < maxConcurrentBuild.toInteger() && kversions.size() != 0) {
def kversion = kversions.pop()
def job_params = [
- new StringParameterValue('mversion', mversion),
+ new StringParameterValue('mversion', mbranch),
+ new StringParameterValue('mgitrepo', mgitrepo),
new StringParameterValue('ktag', kversion.toString()),
new StringParameterValue('kgitrepo', kgitrepo),
]
// Launch the parametrized build
def param_build = job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(job_params))
- println "triggering ${joburl} for the ${mversion} branch on kernel ${kversion}"
+ println "triggering ${joburl} for the ${mbranch} branch on kernel ${kversion}"
// Add it to the ongoing build queue
ongoingBuild.push(param_build)
}
// Abort job if a newer instance is queued
- similarJobQueued = Hudson.instance.queue.items.count{it.task.getFullDisplayName() == currentJobName}
- if ( similarJobQueued > 0 ) {
+ if (!currentJobName.contains("gerrit")) {
+ similarJobQueued = Hudson.instance.queue.items.count{it.task.getFullDisplayName() == currentJobName}
+ if (similarJobQueued > 0) {
+ println "Abort, a newer instance of the job was queued"
build.setResult(hudson.model.Result.ABORTED)
throw new InterruptedException()
+ }
}
def i = ongoingBuild.iterator()