I'm building a python script to pull build history data for Jenkins jobs. I've been successful with this using the Requests library to retrieve the json output, feed into a dataframe, and report on.
I'm noticing it's only pulling the last 100 builds, which looks like the default. I'm testing with a basic curl call, which works fine retrieving the last 100, to see how I can retrieve all builds. I've been searching Google and found one that said to add fetch_all_builds=True, but that still only pulls 100.
Does anyone know how I can request all the builds from a job through an API call?
Thanks
Creating jobs by sending xml file or by specifying params as options with more customization options including source control, notifications, etc. Building jobs (with params), stopping builds, querying details of recent builds, obtaining build params, etc. Listing jobs available in Jenkins with job name filter, job status filter.
If the job is a jenkins pipeline, open the failed build and select the Replay option. Otherwise select the Rebuild option. Thanks for contributing an answer to DevOps Stack Exchange!
Building jobs (with params), stopping builds, querying details of recent builds, obtaining build params, etc. Listing jobs available in Jenkins with job name filter, job status filter. Adding/removing downstream projects. Chaining jobs i.e given a list of projects each project is added as a downstream project to the previous one.
If you want to know how long a job takes to run, then you need to get down to the build level. To get build metadata, you need to call get_build_info (). This method takes in the job name and the build number and returns the metadata as a dictionary. You can do a lot more with the Python Jenkins package.
Adding tree=allBuilds
will give you what you want.
<JENKINS URL>/job/<Job Name>/api/json?tree=allBuilds[*]&depth=2
This is the API Call URL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With