From: Benjamin Drung Date: Tue, 17 Jun 2014 15:39:23 +0000 (+0200) Subject: debian_build.py: Fail build if apt01 upload fail. X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=bcb564895f464509952ba98b075bf5ccf99d3afa;p=profitbricks%2Fjenkins-build-scripts.git debian_build.py: Fail build if apt01 upload fail. --- diff --git a/debian_build.py b/debian_build.py index 18d7b37..9e9cee0 100755 --- a/debian_build.py +++ b/debian_build.py @@ -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()