diff options
author | Bob Mottram <bob.mottram@codethink.co.uk> | 2015-04-01 11:58:12 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-06-12 11:28:01 +0000 |
commit | 7d5758723e8c730eb52615a0dc085bc11ef1b2c0 (patch) | |
tree | d6c8f61c9c748ea1b339f45ab057e73597c7dd4e | |
parent | f01a184b2694d7aa2bc153641b44f89ffcf47687 (diff) | |
download | firehose-7d5758723e8c730eb52615a0dc085bc11ef1b2c0.tar.gz |
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
-rw-r--r-- | firehose/plugin/firehose_plugin.py | 16 |
1 files changed, 12 insertions, 4 deletions
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") |