jenkinsapi
jenkinsapi copied to clipboard
get_downstream_builds returning empty values
ISSUE TYPE
- How to...
Jenkinsapi VERSION
0.3.2
Jenkins VERSION
1.544
SUMMARY
get_downstream_builds() on a known build number is returning empty list.
EXPECTED RESULTS
I am trying to obtain downstream builds from a top level job. I am expecting it to return the list of builds using get_downstream_builds
ACTUAL RESULTS
In the code snippet, where jenkins_url, job_name and build_num are appropriately input to the program, build.get_downstream_builds() is returning empty values. However, I can see all the downstream jobs when I use the job.get_downstream_jobs. I know for a fact that my input build number and build job do have downstream builds. Not sure if I am missing something.
USEFUL INFORMATION
from jenkinsapi.jenkins import Jenkins
from jenkinsapi.build import Build
jenkins = Jenkins(jenkins_url, username=xxxxxx, password=xxxxxx)
job = jenkins.get_job(job_name)
build = Build(jenkins_url, build_num, job)
build_info = build.get_downstream_builds()
print "build list -%s" %build_info
job_info = job.get_downstream_jobs()
print "job list -%s" %job_info
Faced with the same problem with either depth=1 or depth=2: MacOS 10.12.1 Python 3.5.2 jenkinsapi (0.3.3) Jenkins 2.30
Using the default depth=1, I'm getting an empty list of get_downstream_builds. build = Build(jenkins_url, build_num, job) time python3 jenkins_api_test.py [] jenkins_api_test.py 0.47s user 0.08s system 17% cpu 3.077 total
build = Build(jenkins_url, build_num, job, depth=2) time python3 jenkins_api_test.py [] python3 jenkins_api_test.py 14.34s user 1.49s system 26% cpu 59.084 total
Any update on this?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Closed due to inactivity
still an issue! can't we reopen this? I can see the downstream build can get the upstream but not the other way:
print upstream_build.get_downstream_builds() # result = [] :(
print downstream_build.get_upstream_build() # result = `<jenkinsapi.build.Build Application » job_name #job_number>`
I have trouble finding where the Jenkins API is even queried in the code, but according to this answer on SO, there is an action "triggeredBuilds" that gets the information regarding downstream builds from the API. Currently in the code, it seems a little overcomplicated with making use of job information, fingerprints etc.
I can't tell if the answer needs a specific plugin or not though. https://stackoverflow.com/a/53656658