Created
February 10, 2016 14:19
-
-
Save apemberton/047b08bb8a5c63402364 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//master, regular slaves, and shared slaves | |
def nodes = [] | |
(Jenkins.instance.computers.grep { | |
it.class.superclass?.simpleName != 'AbstractCloudComputer' && | |
it.class.superclass?.simpleName != 'AbstractCloudSlave' && | |
it.class.simpleName != 'EC2AbstractSlave' | |
} | |
).each { | |
nodes.add([type:it.class.simpleName, name:it.displayName, executors:it.numExecutors]) | |
} | |
//clouds | |
def clouds = [] | |
Jenkins.instance.clouds.each { | |
def cloud = [type:it.descriptor.displayName, name:it.displayName] | |
try{ | |
cloud.executorsCap = it.templates?.inject(0, {a, c -> a + (c.numExecutors * c.instanceCap)}) | |
}catch(e){} | |
try{ | |
cloud.executorsPerNode = it.numExecutors | |
}catch(e){} | |
clouds.add(cloud) | |
} | |
def host = [type:'Master', name:'Master', url:Jenkins.instance.rootUrl, cores:Runtime.runtime.availableProcessors(), nodes:nodes, clouds:clouds, offline:false] | |
return new groovy.json.JsonBuilder(host).toPrettyString() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment