Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the list of offline Shared agents and bring them online #178

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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 ''