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 e676cac..589b3e5 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 b8fae2d..86f9889 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 49a40e8..d7d8889 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"""