Determine queue time using Groovy script

323 views
Skip to first unread message

Daniel Weber

unread,
May 29, 2015, 10:16:33 AM5/29/15
to jenkins...@googlegroups.com
Hi all,

I was trying to write a small Groovy script that determines queue
times for builds. But somehow the results do
not match my observations. I definitively know that some builds had to
wait for > 10 minutes before an executor
was free. But the script only shows queue times of less than a second.
Here's the script:

jenkins.model.Jenkins jenkins = jenkins.model.Jenkins.instance
for (p in jenkins.projects) {
for (b in p.builds) {
long start = b.startTimeInMillis
long scheduled = b.timeInMillis
queueTime = start - scheduled
println (p.name + " (" + b + ") : " + queueTime + "ms")
}
}

I assumed startTimeMillis is the time when the build was actually
starting to run and timeInMillis is the time when
it was scheduled and entered the queue. Does this make sense?

Any feedback is appreciated :)
Thanks in advance,
Daniel

Baptiste Mathus

unread,
May 31, 2015, 2:26:40 AM5/31/15
to jenkins...@googlegroups.com

In your place I would write a small plugin implementing a http://javadoc.jenkins-ci.org/hudson/model/queue/QueueListener.html class to record time when builds enter and leave the queue.

Cheers

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CA%2Bj7gMTZSC0gw1L3MiMOr45h_5brbKyVRK_tneEQ9hLqd4zWAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages