Adding API Method - Build Job
authorKyle <kyle.rockman@mac.com>
Tue, 11 Jun 2013 21:38:47 +0000 (16:38 -0500)
committerKyle <kyle.rockman@mac.com>
Tue, 11 Jun 2013 21:38:47 +0000 (16:38 -0500)
Added a new method to the api for building a job with params
Job.py was modified to respond better to failures
build.py was modified to be in sync with the remove of .id() on almost
all classes

jenkinsapi/build.py
jenkinsapi/jenkins.py
jenkinsapi/job.py

index e676cac507f2885a112d746754c291d355d9eda1..589b3e597123b6f494cee5a4eddb0cf124ad4351 100644 (file)
@@ -226,7 +226,7 @@ class Build(JenkinsBase):
         count = 0
         while self.is_running():
             total_wait = delay * count
-            log.info("Waited %is for %s #%s to complete" % ( total_wait, self.job.id(), self.id() ) )
+            log.info("Waited %is for %s #%s to complete" % ( total_wait, self.job.name, self.name ) )
             sleep( delay )
             count += 1
 
index b8fae2d95f7a3d32a3d422b352cb482cdbf54c4b..86f9889abb0da0ed51185dd7fde20b281e4ff871 100644 (file)
@@ -163,6 +163,16 @@ class Jenkins(JenkinsBase):
             data='')
         self.poll()
         return self[jobname]
+    
+    def build_job(self, jobname, params={}):
+        """
+        Invoke a build by job name
+        :param jobname: name of exist job, str
+        :param params: the job params, dict
+        :return: none
+        """
+        self[jobname].invoke(params=params)
+        return
 
     def delete_job(self, jobname):
         """
index 49a40e8098cf60c581afb4f1375ccc2927e957d4..d7d888972c60ac7161b7adc36b12517947998827 100644 (file)
@@ -119,8 +119,10 @@ class Job(JenkinsBase, MutableJenkinsThing):
                 log.info( "%s is running.", self.name )
             elif original_build_no < self.get_last_buildnumber():
                 log.info( "%s has completed.", self.name )
+            elif not response.ok :
+                response.raise_for_status()
             else:
-                raise AssertionError("The job did not schedule.")
+                raise AssertionError("The job did not schedule. REASON:%s" % response.reason)
 
     def _buildid_for_type(self, buildtype):
         """Gets a buildid for a given type of build"""