Accessing Slaves

for (String slave: Jenkins.instance.getSlaves()) {
    println slave;

iltering slaves by label substring

def result = []
for (Slave slave: Jenkins.instance.getSlaves()) {
//    println slave.getNodeName() + ": " + slave.getNodeDescription() + ", " + slave.getLabelString();
    if ( slave.getLabelString().contains("farm")) {
      result += slave.getNodeName()
println result.toString()

Code for filtering

Need to add binding for slaves accessor in apply at about line 88.

possible alternate approach

define a parameter plugin which sets a parameter as the node name, or NODE_NAME env variable.
See for instance


attempt 1:

stage "test-build"
node('farm') {
    // clean workspace
    step([$class: 'WsCleanup'])
    // setup env..
    // copy the deployment unit from another Job
    step ([$class: 'CopyArtifact',
          projectName: '5-prepare-tarball',
          filter: 'squid-*-r*.tar.gz']);
    step ([$class: 'CopyArtifact',
          projectName: '5-prepare-tarball',
          filter: 'test-suite-r*.tar.gz']);
    sh "tar xfz squid-*-r*.tar.gz"
    squiddir = sh(returnStdout: true, script: 'ls squid-* | grep -v gz$').trim()
    dir(squiddir) {
        sh 'tar xfz ../test-suite-r*.tar.gz'
        sh './ --verbose --aggressively-use-config-cache'

Discuss this page using the "Discussion" link in the main menu

FrancescoChemolli/JenkinsBits (last edited 2017-01-02 14:36:47 by FrancescoChemolli)