java - count of executors in Jenkins cluster -
i have jenkins cluster, has 1-master 2-executor , 1-agent 2-executor , how total number of executors in jenkins cluster using java or groovy script?
if have access script console, can run this:
final jenkins = jenkins.instance jenkins.computers.inject(0) { acc, item -> acc + item.numexecutors } if running in sandboxed pipeline, have have methods whitelisted administrator in in-process script approval (or through plugin using whitelists) @ http://jenkinsurl/scriptapproval/. won't able use inject right because of jenkins-26481, pipeline script might like:
final jenkins = jenkins.instance int executorcount = 0 (def computer in jenkins.computers) { executorcount += computer.numexecutors } // rest of pipeline if pipeline not run in sandbox, may have access objects without whitelisting.
Comments
Post a Comment