Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins—get "Build Time Trend" values using "Remote Access API"

Is there a way that we can get all Jenkins-"Build Time Trend" information ( Build number + Status[success/failed etc] + Duration ) for an application; using the Jenkins remote access API?

Or else I would appreciate if you could post a link of any documentation on how to get information from Jenkins using the Remote Access API. Most of the sources consist of the way of running jobs, but I couldn't find any, which shows how to fetch information from jenkins.

Thanks!

like image 690
Chathura Kulasinghe Avatar asked Dec 10 '12 11:12

Chathura Kulasinghe


People also ask

How do I get build time in Jenkins pipeline?

You can use ${currentBuild. durationString} to get build duration.

What is Jenkins Remote Access API?

Jenkins API Client is an object oriented ruby wrapper project that consumes Jenkins's JSON API and aims at providing access to all remote API Jenkins provides. It is available as a Rubygem and can be useful to interact with the Job, Node, View, BuildQueue, and System related functionalities.

Can we call an API from Jenkins?

Now we will create the URL for the request.If you do not have an API key, click on Create API Key; now, we can copy it for further use in our Jenkins Project. 3. After we have the API Key, we press on API Documentation. This will open the documentation window.


2 Answers

You can use something like this URL:

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

There's a little more documentation in the root api element:

http://jenkins:8080/job/MY-APPLICATION/api

I admit to not completely understanding the tree parameter. I couldn't find a simple example of retrieving the entire builds subtree.

like image 155
Dave Bacher Avatar answered Nov 10 '22 01:11

Dave Bacher


I admit to not completely understanding the tree parameter. I couldn't find a simple example of retrieving the entire builds subtree.

You can access the entire subtree of an element by using [*] such as http://jenkins:8080/job/MY-APPLICATION/api/json?tree=builds[*]

Cheers,

like image 20
David Avatar answered Nov 10 '22 02:11

David