From 441fd7b455f1295096efea6ea7ea38bfdfb006ef Mon Sep 17 00:00:00 2001 From: Martin Cimbalek Date: Wed, 21 Feb 2024 13:37:27 +0100 Subject: [PATCH] kie-issues-777: fix nodes without docker being assigned for docker jobs (#1184) default label 'ubuntu' will be used as a base for calling avoidFaultyNodes --- .../vars/util.groovy | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/jenkins-pipeline-shared-libraries/vars/util.groovy b/jenkins-pipeline-shared-libraries/vars/util.groovy index ae7c5d288..63c9a9213 100644 --- a/jenkins-pipeline-shared-libraries/vars/util.groovy +++ b/jenkins-pipeline-shared-libraries/vars/util.groovy @@ -560,12 +560,12 @@ void waitForDocker() { * Method to wrap original label and exclude nodes that were marked as faulty in some of the parent folders. * Example usage in agent block: `label util.avoidFaultyNodes('ubuntu')` * `FAULTY_NODES` environment variable is inherited down the folder tree and available in jobs. - * @param label Node label to be used + * @param label Node label to be used. If empty, 'ubuntu' will be used as default * @return Node label extended with an expression ensuring to exclude nodes marked as faulty. */ -String avoidFaultyNodes(String label) { - if (label == null || label.isEmpty()) { - return avoidFaultyNodes() +String avoidFaultyNodes(String label = 'ubuntu') { + if (label.isEmpty()) { + label = 'ubuntu' } String faultyNodesString = env.FAULTY_NODES if((faultyNodesString == null) || faultyNodesString.isEmpty()) { @@ -575,19 +575,3 @@ String avoidFaultyNodes(String label) { String result = "(${label}) && !(${String.join(' || ', faultyNodes)})" return result.toString() } - -/** - * Method to exclude nodes that were marked as faulty in some of the parent folders. - * Example usage in agent block: `label util.avoidFaultyNodes()` - * `FAULTY_NODES` environment variable is inherited down the folder tree and available in jobs. - * @return Node label expression ensuring to exclude nodes marked as faulty. - */ -String avoidFaultyNodes() { - String faultyNodesString = env.FAULTY_NODES - if((faultyNodesString == null) || faultyNodesString.isEmpty()) { - return '!dummyLabel' // we need to put something here because label without parameter would cause compile error - } - String[] faultyNodes = faultyNodesString.split(',') - String result = "!(${String.join(' || ', faultyNodes)})" - return result.toString() -}