While using the Jenkins Docker Plugin, probably because of an error, swarms cannot be launched. I didn't pay attention and at the moment I have thousands of offline nodes, that were failed to launch.
BOTTOM LINE - Is there a way to batch remove nodes (slaves) in Jenkin, clean all offline nodes or even delete all nodes? Restating the Jenkins server didn't help, and I couldn't find a way in the Jenkins API.
Will appreciate any idea, before I'm starting to write a Selenium script or something...
Many thanks!
Use Authorize Project plugin to assign authentication to your builds. Then Just set Computer/Build permissions for you nodes (Can be done in Role Strategy plugin for example) Use Job Restrictions Plugin to restrict access to node via Node properties.
Deleting a single agentOn the Agents page, click the Delete Agent link in the Action column for the agent you want to delete. This action removes the agent from the database. On the Agent Details page, click Delete Agent to delete that displayed agent.
The Jenkins master acts to schedule the jobs, assign slaves, and send builds to slaves to execute the jobs. It will also monitor the slave state (offline or online) and get back the build result responses from slaves and the display build results on the console output.
This is the Copy>Paste>Run
version of KeepCalmAndCarryOn answer.
Go to manage Jenkins > Script Console > copy & paste this code > Run
for (aSlave in hudson.model.Hudson.instance.slaves) {
if (aSlave.getComputer().isOffline()) {
aSlave.getComputer().setTemporarilyOffline(true,null);
aSlave.getComputer().doDoDelete();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With