From 9863516d62090bcbf32fff2312ec979b3e23c815 Mon Sep 17 00:00:00 2001 From: Will Maier Date: Tue, 10 Jul 2012 13:49:48 -0500 Subject: [PATCH] Add and use build_info(). --- autojenkins/jobs.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/autojenkins/jobs.py b/autojenkins/jobs.py index 12af0fc..f64be13 100644 --- a/autojenkins/jobs.py +++ b/autojenkins/jobs.py @@ -11,6 +11,7 @@ BUILD = '{0}/job/{1}/build' CONFIG = '{0}/job/{1}/config.xml' JOBINFO = '{0}/job/{1}/' + API +BUILDINFO = '{0}/job/{1}/{2}/' + API LIST = '{0}/' + API LAST_SUCCESS = '{0}/job/{1}/lastSuccessfulBuild/' + API TEST_REPORT = '{0}/job/{1}/lastSuccessfulBuild/testReport/' + API @@ -99,12 +100,24 @@ def job_info(self, jobname): response = self._get(JOBINFO, jobname) return eval(response.content) + def build_info(self, jobname, build_number=None): + """ + Get information for a build of a job. + + If no build number is specified, defaults to the most recent build. + """ + if build_number is not None: + args = (BUILDINFO, jobname, build_number) + else: + args = (LAST_BUILD, jobname) + response = self._get(*args) + return eval(response.content) + def last_build_info(self, jobname): """ Get information for last build of a job. """ - response = self._get(LAST_BUILD, jobname) - return eval(response.content) + return self.build_info(jobname) def last_build_report(self, jobname): """