我可以通过远程API找到关于我的Jenkins服务器的所有内容,但不能找到当前正在运行的作业列表.
这个,
http://my-jenkins/computer/api/json
要么
http://my-jenkins/computer/(master)/api/json
看起来似乎是最合乎逻辑的选择,但他们没有说什么(除了工作数量)关于哪些工作实际运行.
有没有办法通过系统Groovy脚本获取Jenkins中的RUNNING构建列表?我尝试循环繁忙的执行程序,但是从执行程序对象,我无法获取构建对象:
def busyExecutors = Jenkins.instance.computers
                                .collect { 
                                  c -> c.executors.findAll { it.isBusy() }
                                }
                                .flatten() // reminder: transforms list(list(executor)) into list(executor)
busyExecutors.each { e -> 
  println('=====print out methods of executor object=======');
  println e.metaClass.methods*.name.sort().unique();
}
我也可以针对我感兴趣的JOB:
def item = hudson.model.Hudson.instance.getItem("my_job");
println item.metaClass.methods*.name.sort().unique(); 
但是,我将不得不循环遍历100s(如果不是更多)构建并询问每个构建是否正在运行.
必须有一种更容易/更好的方法来获取正在运行的构建列表.
有很多关于如何通过System Groovy Scripts(我写的一些)做各种事情的信息,但我无法弄清楚如何获得正在运行的构建列表:
如何使用groovy在jenkins中获取当前正在运行的作业节点名称
https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console