Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions shared-agent-bring-onine.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
Author: Harish Jangam
Description: Get the list of offline Shared agents and bring them online
**/

import hudson.slaves.*
import static com.cloudbees.opscenter.server.persistence.SlaveLeaseTable.getLeases;


def SharedAgentstatus(Slave) {
def online = false
if (Slave instanceof com.cloudbees.opscenter.server.model.SharedSlave) {
online = Slave.getOfflineCause() == null
if(!online){
println(Slave.name + ' is currently Offline, hence bringing it online \t')
//Slave.doEnable() // comment - to get the list of offline agents, // Uncomment - to bring the agent online
}
}
}

Jenkins.instance.allItems.grep {
it.class.name == 'com.cloudbees.opscenter.server.model.SharedSlave'
}.each {
SharedAgentstatus(it)
}
println ''