how to get build number for jenkins job via python code -
i developing python code deal jenkins using jenkinsapi package. looking simple way pass job name , latest build number job. example
from jenkinsapi import jenkins ci_jenkins_url = "job url" username = none token = none job = "test 3" j = jenkins.jenkins(ci_jenkins_url, username=username, password=token) if __name__ == "__main__": j.build_job(job)
this triggering builds successfully, need build number proceeding further. highly appreciated
the job object implements several methods getting build number of last build, last completed build, last stable build, etc.
jenkins_server = jenkins.jenkins(ci_jenkins_url, username=username, password=token) my_job = jenkins_server.get_job('my job name') last_build = my_job.get_last_buildnumber()
you can use python interactively explore api packages don't have complete online documentation:
>>> jenkins_server = jenkins.jenkins(...) >>> job = jenkins_server.get_job('my job name') >>> help(job)
Comments
Post a Comment