Skip to content

Instantly share code, notes, and snippets.

@jalex19100
Created November 2, 2024 04:09
Show Gist options
  • Save jalex19100/cbf822c3f61703efb829c9ccc17a8c62 to your computer and use it in GitHub Desktop.
Save jalex19100/cbf822c3f61703efb829c9ccc17a8c62 to your computer and use it in GitHub Desktop.
Delete all ECS slave nodes. If they are inactive in ECS, the exception will be ignored. Useful in runaway slaves or node issues.
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') {
try {
println('Shutting down node!!!!');
aSlave.getComputer().setTemporarilyOffline(true,null);
aSlave.getComputer().doDoDelete();
println('\tcomputer.getLog: ' + aSlave.getComputer().getLog());
println('\tcomputer.getBuilds: ' + aSlave.getComputer().getBuilds());
} catch (Exception e) {
println(e.getMessage());
}
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment