Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get last build date of a job from Jenkins in Java

I have a job scheduled in Jenkins and it has lets say 370 total builds. I can see the date right next to build number in the build history part of the page but when I try to access the JSON content of that page like http:localhost:8080/job/job_name/api/json I am not getting that date for the latest build in that JSON content.

Any other way to access the date when the last build happended?

I have to use the same in Java so might be there is any API to access the Jenkins?

like image 376
Himanshu Gupta Avatar asked Dec 25 '22 03:12

Himanshu Gupta


1 Answers

As Harshavardhan Konakanchi mentioned in his answer there's the /lastBuild/ URL path. You can get exactly the information you want by using:

<JENKINS_URL>/job/<JOB_NAME>/lastBuild/api/json?tree=timestamp

Example output:

{"timestamp":1467898403630}

See <JENKINS_URL>/job/<JOB_NAME>/lastBuild/api/ for a description of the API.

like image 88
Gerold Broser Avatar answered Dec 27 '22 12:12

Gerold Broser