import hudson.model.*;
import hudson.AbortException;
import jenkins.model.Jenkins;
@NonCPS
def allNodes = jenkins.model.Jenkins.instance.nodes
def triggerJob = false
for (String node: allNodes) {
if ( node.getComputer().isOnline() && node.nodeName == "ABC" ) {
println node.nodeName + " " + node.getComputer().countBusy() + " " +
node.getComputer().isAcceptingTasks()
triggerJob = true
break
}
}
if (triggerJob) {
println("triggering build as node is available")
build job: 'jobName', parameters:
[
/** list of string Parameters **/
]
}
上面的作业触发了构建,但失败了:
发生的异常:在字段 hudson.model.Slave.launcher 中导致:java.io.NotSerializableException:hudson.slaves.JNLPLauncher