For those who stumble upon this problem I got around it by
using OfflineCause.UserCause instad of OfflineCause.SimpleOfflineCause. For
me it looks like this
def NodeDisconnect (NodeName) {
println("Node Disconnect")
def WorkNode = jenkins.model.Jenkins.instance.getNode(NodeName)
if (WorkNode) {
println ("GOT NODE")
def WorkComputer = WorkNode.computer
def WorkLouncher = WorkComputer.getLauncher();
def WorkListener = TaskListener.NULL
if (WorkComputer.isOnline()){
println("Node is online")
if (WorkComputer.isIdle()){
println ("Current node status Online, Idle with
${WorkComputer.countExecutors()}:${WorkComputer.countBusy()} executors")
println ("About to disconnect node")
def WorkOfflineCause = new
OfflineCause.UserCause(User.current(),'Disconnected for VirtualBox snapshot
restore...')
WorkLouncher.beforeDisconnect(WorkComputer,WorkListener)
WorkComputer.disconnect(WorkOfflineCause);
WorkLouncher.afterDisconnect(WorkComputer,WorkListener)
println ("Wait for node to go offline")
WorkComputer.waitUntilOffline()
}
else {
println ("Current node status Online, Busy with
${WorkComputer.countExecutors()}:${WorkComputer.countBusy()} executors")
//raise
}
}
else {
println("Node is offline with
cause:${WorkComputer.getOfflineCauseReason()}")
//raise
}
}
else {
println ("NODE NOT FOUND")
//raise error
}
}
--
You received this message because you are subscribed to the Google Groups
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-dev/0291228d-2d8c-4bcd-932c-8f122a444d78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.