How can I find out how long Jenkins' work has been in the waiting line after completing work?

For statistics, I want to see how long the task is in the waiting queue, so I can configure the system to complete the task on time.

If the job is only in the queue, it can be found in the waiting queue on the first page, see How can I find out how long Jenkins has been in the waiting queue?

Or http://<jenkins_url>/queue/api/json?pretty=true

Can I check somewhere to get the "Waiting time in queue" for a specific job after the job is completed?

It will be good if it can be obtained in the public jenkins API.

+7
jenkins groovy
source share
1 answer

// received a response from a colleague

This can be achieved by installing Jenkins Metrics Plugin after installing it on the assembly results page, you will see

time wait in queue

Jenkins REST API Then you can get the queue timeout from http: // localhost: 8080 / job / demo / 1 / api / json? Pretty = true & depth = 2 . queuingDurationMillis is the data I wanted.

 "actions" : [ { "queuingDurationMillis" : 33, "totalDurationMillis" : 3067 } ], 

Groovy script . Also we can get this data in groovy through internal data, check below code in Jenkins Script console <a2>

 job = hudson.model.Hudson.instance.getItem("demo") build = job.getLastBuild() action = build.getAction(jenkins.metrics.impl.TimeInQueueAction.class) println action.getQueuingDurationMillis() 

You can see the demo using the docker by running below and open in the browser for demo job

 docker run -it -p 8080:8080 larrycai/jenkins-metrics 
+14
source share

All Articles