From 7d5758723e8c730eb52615a0dc085bc11ef1b2c0 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 1 Apr 2015 11:58:12 +0100 Subject: Raise exception on gerrit push failure This also deletes the hash file if a failure occurs, so that it's possible to retry Change-Id: I169fc822b7e4f994b80ad331bb9a16fdfe2961bc --- firehose/plugin/firehose_plugin.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'firehose') diff --git a/firehose/plugin/firehose_plugin.py b/firehose/plugin/firehose_plugin.py index dbce376..ace7bdf 100644 --- a/firehose/plugin/firehose_plugin.py +++ b/firehose/plugin/firehose_plugin.py @@ -199,8 +199,7 @@ class FirehosePlugin(cliapp.Plugin): self.morphs.traverse_specs(process_spec, wanted_spec) if len(urls) != 1: # Remove the previously recorded hash - if self.sha_filename != "": - os.remove(self.sha_filename) + os.remove(self.sha_filename) raise cliapp.AppException( "Woah! expected 1 chunk matching %s:%s (got %d)" % ( stratum, chunk, len(urls))) @@ -310,5 +309,14 @@ class FirehosePlugin(cliapp.Plugin): cwd=self.gitpath) logging.info('commit_and_push: ' + str(code)) if code == 0: - self.app.runcmd(['git', 'push', 'ssh://'+gerrit_username+'@'+gerrit_url+ - ':29418/baserock/baserock/definitions', branch_name], cwd=self.gitpath) + try: + # Note: cliapp needs updating such that it supports callbacks + self.app.runcmd(['git', 'push', + 'ssh://'+gerrit_username+'@'+gerrit_url+ + ':29418/baserock/baserock/definitions', + branch_name], cwd=self.gitpath) + except cliapp.AppException: + # Remove the previously recorded hash + os.remove(self.sha_filename) + raise cliapp.AppException( + "Woah! unable to push changes to gerrit") -- cgit v1.2.1