merge some stuff
authorsalimfadhley <sal@stodge.org>
Sun, 23 Jun 2013 00:04:57 +0000 (01:04 +0100)
committersalimfadhley <sal@stodge.org>
Sun, 23 Jun 2013 00:04:57 +0000 (01:04 +0100)
1  2 
jenkinsapi/job.py

index 02d294364be8ae4ed902ea495d2af3b26dff867a,bf636ce3bcbbfc11d3d03d9e54180fbdc0229446..6cf89753d836a16bf087ac2319bea8ef9c854688
@@@ -130,45 -140,32 +140,41 @@@ class Job(JenkinsBase, MutableJenkinsTh
                  total_wait += invoke_block_delay
              if self.is_running():
                  running_build = self.get_last_build()
-                 running_build.block_until_complete( delay=invoke_pre_check_delay )
-             assert self.get_last_buildnumber() > original_build_no, "Job does not appear to have run."
-         else:
-             if self.is_queued():
-                 log.info( "%s has been queued.", self.name )
-             elif self.is_running():
-                 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. REASON:%s" % response.reason)
+                 running_build.block_until_complete(
+                     delay=invoke_pre_check_delay)
  
      def _buildid_for_type(self, buildtype):
+         self.poll()
          """Gets a buildid for a given type of build"""
-         KNOWNBUILDTYPES=["lastSuccessfulBuild", "lastBuild", 
-                 "lastCompletedBuild", "lastFailedBuild"]
+         KNOWNBUILDTYPES = [
 -            "lastSuccessfulBuild", "lastBuild", "lastCompletedBuild", "firstBuild"]
++            "lastSuccessfulBuild",
++            "lastBuild",
++            "lastCompletedBuild",
++            "firstBuild"]
          assert buildtype in KNOWNBUILDTYPES
-         if self._data[buildtype] == None:
-             return None
-         buildid = self._data[buildtype]["number"]
-         assert type(buildid) == int, "Build ID should be an integer, got %s" % repr( buildid )
-         return buildid
+         if not self._data[buildtype]:
+             raise NoBuildData(buildtype)
+         return self._data[buildtype]["number"]
+     def get_first_buildnumber(self):
+         """
+         Get the numerical ID of the first build.
+         """
+         return self._buildid_for_type("firstBuild")
  
-     def get_last_good_buildnumber( self ):
+     def get_last_good_buildnumber(self):
          """
          Get the numerical ID of the last good build.
          """
-         return self._buildid_for_type(buildtype="lastSuccessfulBuild")
+         return self._buildid_for_type("lastSuccessfulBuild")
  
 -    def get_last_buildnumber(self):
 +    def get_last_failed_buildnumber( self ):
 +        """
 +        Get the numerical ID of the last good build.
 +        """
 +        return self._buildid_for_type(buildtype="lastFailedBuild")
 +
 +    def get_last_buildnumber( self ):
          """
          Get the numerical ID of the last build.
          """
      def get_build_dict(self):
          if not self._data.has_key("builds"):
              raise NoBuildData(repr(self))
-         return dict((build["number"], build["url"]) 
 -        return dict((a["number"], a["url"]) for a in self._data["builds"])
++        return dict((build["number"], build["url"])
 +                        for build in self._data["builds"])
  
      def get_revision_dict(self):
          """