RECOMMENDED Amnezia Premium: Works Where Other VPNs Fail

Unblockable AmneziaWG 2.0 & XRay protocols. Perfect for lag-free access to ChatGPT, Claude AI, global freelance marketplaces, and restricted streaming networks with clean RAM-only privacy.

Delete all offline Jenkins nodes/slaves in Unix/Linux

Delete all offline Jenkins nodes/slaves in Unix/Linux

When you use the slave in Jenkins, there is always a chance that some of the node will no longer exist due to some reason (E.g. network problems; closed port). And if it is a PROD server and it needs to gather projects. For a certain period of time you can gather a large number of disabled cars.

Useful reading:

Installing Jenkins and Jenkins-slave in Unix/Linux

The autobuild Java projects using Jenkins in Unix/Linux

Language setup in Jenkins

Permissions in Jenkins

Monitoring space on server using Jenkins

Setting the theme for Jenkins

Edit/Change password for user Jenkins

Create a Jenkins backup/restore Unix/Linux

The autobuild Java projects using Jenkins in Unix/Linux

I found a few solutions how to do it. Show a visual example of how I managed to kill over 1.5 to zombie nodes.

Jenkins delete all offline nodes

So, one way to delete all offline hosts is to run Groovy script using the Jenkins console. For this, you need Selaginella in Sam Jenkins, then click on “Manage Jenkins” and go to the “script Console”:

In the script, insert:

Closure query = { it.name ==~ /^.*$/ } Closure action = { println('====================') println("Name: ${it.name}") println("LabelString: ${it.labelString}") println("NumExectutors: ${it.numExecutors}") println("RemoteFS: ${it.remoteFS}") println("Mode: ${it.mode}") println("RootPath: ${it.rootPath}") println("Offline: ${it.computer.offline}") if (it.computer.offline) { println("Deleting node: ${it.name}") it.computer.doDoDelete() } } Jenkins.instance.slaves.findAll(query).each(action) return

Click on “RUN” and if a lot of hosts — it takes some time. This example is fully used to PROD the servers the company where I work.

Delete all Jenkins slaves offline

Checked out a different approach of the script to Groovy. A fully working version. To remove a disconnected slave, you need Selaginella in Sam Jenkins, then click on “Manage Jenkins” and go to the “script Console”:

In the script, insert:

for (aSlave in hudson.model.Hudson.instance.slaves) { if (aSlave.getComputer().isOffline()) { aSlave.getComputer().setTemporarilyOffline(true,null); aSlave.getComputer().doDoDelete(); } }

Click on “RUN” and if a lot of hosts — it takes some time. This example is fully used to PROD the servers the company where I work.

To me these solutions helped and they all work. Thou are more ideas than can be supplemented — will complement the subject.

That’s all, “the Delete all offline Jenkins nodes/slaves in Unix/Linux” is completed.

Source: linux-notes.org

🛠️ Top Temporary VPS for Testing & Experiments (2026)

Need a fast cloud server for a few hours or days? Deploy an isolated testing environment, run your scripts, and destroy it without any monthly commitments. Secure payments via Crypto (USDT) & PayPal supported.

AÉZA — Ultimate Testing Environment Flexible rates: from €0.01/hr depending on the billing period (the longer you rent, the cheaper it gets).
Exclusive Welcome Bonus: Get an extra 15% on your first balance top-up within 24 hours after registration.
Deploy on Aeza
Friendhosting — High-Storage VDS Hourly VDS infrastructure (from €0.03/hr) deployed across massive global locations.
• Best-in-class Storage VDS configurations with huge disk space for heavy data testing.
Deploy on Friend
Zomro — Premium Daily Node Daily billing model starting at just €0.16/day (~€0.007/hr) for optimal cost control.
• High-speed hardware platform with a stable presence in the Netherlands (Europe).
Deploy on Zomro
Rork

Linux hobbyist into networking and digital privacy. I use this hub to translate and store technical notes on sysadmin tasks and anonymity tools. Tech should work for people, not the other way around.

Rate author
Add a comment