How to get the list of jobs with the longest build time in Jenkins

I need to create a weekly report on our Jenkins build cluster. One report is to display a list of jobs with the longest build time.

The solution that I can come up with is to analyze the "Assembly History" page on each subordinate (also the lead) and for each task assembly, analyze the assembly page and look for "Take x min x sec on slave-xx".

This seems rather cumbersome, does anyone know a better solution using the Jenkins API or the Groovy script console?

thanks

+6
source share
2 answers

You can get assembly data for your report through the Jenkins API. For this work, you can extract a list of collections with information about the duration using something like:

http://jenkins:8080/job/my-job/api/json?tree=builds[id,number,duration,timestamp,builtOn]

To view a list of all the assembly data available by the API for this job:

http://jenkins:8080/job/my-job/api/json?tree=builds[*]

As soon as you have a request that receives the job information that you need for your report should be simple to sort through the work.

Most Jenkins pages have a link at the bottom of the REST API that describes a bit of API access for this page, for example. http://jenkins:8080/job/my-job/api .

+10
source

Source: https://habr.com/ru/post/974756/


All Articles