简体   繁体   中英

python-jenkins get_job_info - how do I get info on more than 100 builds?

I'm using the python-jenkins api to manage some jenkins build servers. The servers are pretty loaded - scores of jobs and some jobs have saved hundreds of builds.

A basic goal I have is to use the API to get the build count for each job, and a total build count across all jobs. Here's the code:

import jenkins
jnk = jenkins.Jenkins(myUrl, myUsername, myPassword)
info = jnk.get_info()
jobs = info['jobs']
totalBuildCount = 0

for job in jobs:
    jobName = job['name']
    jobinfo = jnk.get_job_info(jobName)
    builds = jobinfo['builds'] # never contains more than 100 items
    print jobName + " build count: " + str(len(builds))
    totalBuildCount += len(builds)

print "Total build count: " + str(totalBuildCount)

What I find - unfortunately - is that the builds array in the job info dictionary never contains more than 100 entries, even if the job has stored many more builds than that.

Have others seen this limit, and is there any way around it, or is this API just useless for servers with large archived build counts?

If could use jenkinsapi instead:

from jenkinsapi.jenkins import Jenkins
jnk = Jenkins(myUrl, myUsername, myPassword)
totalBuildCount = 0

for job in jnk.keys():
    builds = jnk[job].get_build_dict()
    print job + " build count: " + str(len(builds))
    totalBuildCount += len(builds)

print "Total build count: " + str(totalBuildCount)

当使用 python-jenkins 模块获取超过 100 个构建时,使用fetch_all_builds=True调用get_job_info函数

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM