17

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!

Chathura Kulasinghe
  • 2,640
  • 5
  • 23
  • 23
  • 1
    I could get something done by using this mechanism. `http://localhost:8080/job/MY-APPLICATION/BUILD#/api/json` Using this, I will be able to run a loop, call this again and again changing the BUILD# and get information of each build. But it will be great if I have a way of getting all the information with a one call (as a collection) which would reduce the overhead. If you have an idea about such a mechanism, please do help me with this matter. Thanks. – Chathura Kulasinghe Dec 10 '12 at 11:43

3 Answers3

19

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.

Dave Bacher
  • 15,652
  • 3
  • 63
  • 86
9

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,

David
  • 113
  • 1
  • 5
9

For retrieving ALL builds, use

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

Note that B is capitalized in allBuilds

Aravind Murthy
  • 501
  • 6
  • 8