I\'m creating a Jenkins pipeline job and I need to run a job on all nodes labelled with a certain label.
Therefore I\'m trying to get a list of node names assigned with
Here is a functional solution which is more readable and concise:
def nodes = jenkins.model.Jenkins.get().computers .findAll{ it.node.labelString.contains(label) } .collect{ it.node.selfLabel.name }
You can verify it in the Jenkins Script Console.