I am looking for script like this for a long time, but could not find anyway, so I post here, hopefully it’s useful for someone.
def busyExecutors = Jenkins.instance.computers.collect {
c -> c.executors.findAll { it.isBusy() }
}.flatten()
def nodename = 'n12345'
busyExecutors.each { e ->
if(e.getOwner().getDisplayName() == nodename){
job = e.getCurrentExecutable().getParent()
lastbuild = job.getOwnerTask().getLastBuild()
println "'${lastbuild.getFullDisplayName()}' is currently running on '${nodename}', with building time: ${e.getTimestampString()}"
}
}
'test-test Cookbook #58' is currently running on 'n12345', with building time: 10 min