support "ondemand" platforms

This commit is contained in:
2024-05-22 14:58:57 +03:00
parent 6b93814f10
commit 032443049e
2 changed files with 9 additions and 4 deletions

View File

@@ -23,6 +23,7 @@ Next you should register this library in Jenkins -> System settings -> Global Pi
* `stageSuffix` - suffix string for `stage`
* `whiteList` - array of permitted names, ignored if empty
* `blackList` - array of denied names, ignored if empty
* `ondemand` - if true then process also ondemand platforms
`whiteList` and `blackList` are case-insensitive, and can be part of platform name

View File

@@ -21,7 +21,8 @@ class Platforms {
public void forEach(Map args, functor) {
def prefix = args.stagePrefix ?: ""
def suffix = args.stageSuffix ?: ""
filterJSON(args.whiteList ?: [], args.blackList ?: []).each { key, dist ->
def ondemand = args.ondemand ?: false
filterJSON(args.whiteList ?: [], args.blackList ?: [], ondemand).each { key, dist ->
def toolchain = dist.cmake_toolchain ?: ""
if (toolchain != "") toolchain = "-DCMAKE_TOOLCHAIN_FILE=${toolchain}"
steps.stage ("${prefix}${key}${suffix}") {
@@ -32,11 +33,14 @@ class Platforms {
public void forEach(functor) { forEach(functor, stagePrefix: "") }
//@NonCPS
private Boolean filterDist(name, dist, whiteList, blackList) {
private Boolean filterDist(name, dist, whiteList, blackList, ondemand) {
if (!dist.enabled) {
return false;
}
def in_white = true, in_black = false
if (dist.containsKey('ondemand'))
in_white = !dist.ondemand
if (ondemand) in_white = true
def dn = name.toLowerCase()
if (whiteList.size() > 0) {
in_white = false
@@ -46,10 +50,10 @@ class Platforms {
return in_white && !in_black
}
private def filterJSON(whiteList, blackList) {
private def filterJSON(whiteList, blackList, ondemand) {
def ret = [:]
_root.Platforms.each({name, dist ->
if (filterDist(name, dist, whiteList, blackList))
if (filterDist(name, dist, whiteList, blackList, ondemand))
ret[name] = dist
})
return ret