I want to accomplish, through a script using the Jenkins API, the equivalent of manually clicking on the "Disconnect" link on the node management page in Jenkins. I want to add this code to a script I made using the Pipeline scripting plugin.
In other words, as a user with Jenkins admin privileges, do
Manage Jenkins -> Manage Nodes -> Click on a node -> Click on "Disconnect"
As in:

I do not want to do the equivalent of "temporarily mark this node as offline".
That is not useful to me.
The hudson.model.Computer class has a disconnect(DisconnectReason) method
Here are the docs for this
In my case, I was able to acquire the Computer instance and disconnect by using Jenkins.instance.getNode(...).getComputer().disconnect(...)
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