]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
debian_build.py: Fail build if apt01 upload fail.
authorBenjamin Drung <benjamin.drung@profitbricks.com>
Tue, 17 Jun 2014 15:39:23 +0000 (17:39 +0200)
committerBenjamin Drung <benjamin.drung@profitbricks.com>
Tue, 17 Jun 2014 15:39:23 +0000 (17:39 +0200)
debian_build.py

index 18d7b37e7a3298f82131a029a21fd33a404072a5..9e9cee0c9576fe6d1440556fef74a72107e2df82 100755 (executable)
@@ -117,7 +117,7 @@ def upload_to_apt_repository(apt_target, apt_dist, changes_file, logger):
         else:
             logger.warn('%s failed.' % command)
             figlet('apt01 upload failed')
-            return
+            return False
         (head, tail) = os.path.splitext(changes_file)
         new_changes_file = head + '_apt01' + tail
         filehandle = open(new_changes_file, 'w')
@@ -127,16 +127,19 @@ def upload_to_apt_repository(apt_target, apt_dist, changes_file, logger):
         cmd = ['dput', apt_target, new_changes_file]
         command = ' '.join(cmd)
         logger.debug('Executing "{command}" ...'.format(command=command))
-        if subprocess.call(cmd) == 0:
+        success = subprocess.call(cmd) == 0
+        if success:
             logger.debug('%s succeeded.' % command)
             figlet('apt01 upload OK')
         else:
             logger.warn('%s failed.' % command)
             figlet('apt01 upload failed')
     except Exception as error:
-        logger.warning("Experimental upload to http://apt01.pb.local failed. "
+        logger.warning("Upload to http://apt01.pb.local failed. "
                        "See above for details.", exc_info=error)
         figlet('apt01 upload failed')
+        success = False
+    return success
 
 
 if __name__ == '__main__':
@@ -695,7 +698,8 @@ export {builder_env} FORCE_SHELL=TRUE
             fh.close()
 
             # upload to new apt01 archive
-            upload_to_apt_repository(apt_target, apt_dist, changes_file, logger)
+            if not upload_to_apt_repository(apt_target, apt_dist, changes_file, logger):
+                exit_error()
 
             # upload changes file
             dput_obj.configure()