Skip to content

Instantly share code, notes, and snippets.

@gwsu2008
Created June 24, 2020 16:25
Show Gist options
  • Save gwsu2008/c4ef2f419f93f72e2e408b50d6e84c09 to your computer and use it in GitHub Desktop.
Save gwsu2008/c4ef2f419f93f72e2e408b50d6e84c09 to your computer and use it in GitHub Desktop.
remove-jenkins-offline-nodes
for (aSlave in hudson.model.Hudson.instance.slaves) {
if (aSlave.getComputer().?isOffline()) {
aSlave.getComputer().setTemporarilyOffline(true,null);
aSlave.getComputer().doDoDelete();
}
}
for (aSlave in hudson.model.Hudson.instance.slaves) {
println('====================');
println('Name: ' + aSlave.name);
println('getLabelString: ' + aSlave.getLabelString());
println('getNumExectutors: ' + aSlave.getNumExecutors());
println('getRemoteFS: ' + aSlave.getRemoteFS());
println('getMode: ' + aSlave.getMode());
println('getRootPath: ' + aSlave.getRootPath());
println('getDescriptor: ' + aSlave.getDescriptor());
println('getComputer: ' + aSlave.getComputer());
println('\tcomputer.isAcceptingTasks: ' + aSlave.getComputer().isAcceptingTasks());
println('\tcomputer.isLaunchSupported: ' + aSlave.getComputer().isLaunchSupported());
println('\tcomputer.getConnectTime: ' + aSlave.getComputer().getConnectTime());
println('\tcomputer.getDemandStartMilliseconds: ' + aSlave.getComputer().getDemandStartMilliseconds());
println('\tcomputer.isOffline: ' + aSlave.getComputer().isOffline());
println('\tcomputer.countBusy: ' + aSlave.getComputer().countBusy());
//if (aSlave.name == 'NAME OF NODE TO DELETE') {
// println('Shutting down node!!!!');
// aSlave.getComputer().setTemporarilyOffline(true,null);
// aSlave.getComputer().doDoDelete();
//}
println('\tcomputer.getLog: ' + aSlave.getComputer().getLog());
println('\tcomputer.getBuilds: ' + aSlave.getComputer().getBuilds());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment