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

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -