Jenkins command to get number of builds in queue

前端 未结 5 1109
傲寒
傲寒 2021-01-04 00:54

I am trying to get the number of builds in the Jenkins Build Queue.

May I know the Jenkins command to get the number of builds running in the queue ?

5条回答
  •  长情又很酷
    2021-01-04 01:40

    That's easy to do with Jenkins Script Console:

    println Hudson.instance.queue.items.length
    // => 2
    

    Also that's possible to execute groovy script remotely. For example, from command line:

    $ curl -u username:password -d "script=println Hudson.instance.queue.items.length" jenkins_url/scriptText
    2
    

    Note: user with specified username should have access to Jenkins Script Console.

提交回复
热议问题