Skip to content

Commit

Permalink
kie-issues-777: fix nodes without docker being assigned for docker jo…
Browse files Browse the repository at this point in the history
…bs (#1184)

default label 'ubuntu' will be used as a base for calling avoidFaultyNodes
  • Loading branch information
cimbalek authored Feb 21, 2024
1 parent 5625032 commit 441fd7b
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions jenkins-pipeline-shared-libraries/vars/util.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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()
}

0 comments on commit 441fd7b

Please sign in to comment.