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

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -