Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get the specify build use get_build(number) #81

Closed
shuaibingn opened this issue May 25, 2023 · 3 comments
Closed

Cannot get the specify build use get_build(number) #81

shuaibingn opened this issue May 25, 2023 · 3 comments

Comments

@shuaibingn
Copy link

I know that only the first 100 builds are obtained now, but get_build(number) should be free to specify the build number to be reasonable

def get_build(self, number):
    for item in self.api_json(tree='allBuilds[number,displayName,url]')['allBuilds']:
        if number == item['number'] or number == item['displayName']:
            return self._new_instance_by_item('api4jenkins.build', item)
    return None

So it should be fine to change it to the above, except that it may be slower

@joelee2012
Copy link
Owner

@shuaibingn thanks for creating PR. However as described in api doc: https://ci.jenkins.io/job/Core/job/jenkins/job/master/api/

Retrieving all builds

To prevent Jenkins from having to load all builds from disk when someone accesses the job API, the builds tree only contains the 50 newest builds. If you really need to get all builds, access the allBuilds tree, e.g. by fetching …/api/xml?tree=allBuilds[…]. Note that this may result in significant performance degradation if you have a lot of builds in this job. 

so it does not make sense to get all builds by default, instead you can use another method job.iter_all_builds

@shuaibingn
Copy link
Author

@shuaibingn thanks for creating PR. However as described in api doc: https://ci.jenkins.io/job/Core/job/jenkins/job/master/api/

Retrieving all builds

To prevent Jenkins from having to load all builds from disk when someone accesses the job API, the builds tree only contains the 50 newest builds. If you really need to get all builds, access the allBuilds tree, e.g. by fetching …/api/xml?tree=allBuilds[…]. Note that this may result in significant performance degradation if you have a lot of builds in this job. 

so it does not make sense to get all builds by default, instead you can use another method job.iter_all_builds

I found such an API after looking at the jenkins api
job_name/<build_number>/api/json
Should be able to get specific builds faster

Using such an API in the latest submission, I rewrote the api_json() method in Job so that it can support the param url

@joelee2012
Copy link
Owner

Don't do that since it makes misunderstanding and additional complex

@joelee2012 joelee2012 added question Further information is requested and removed question Further information is requested labels May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants