Skip to content

Commit

Permalink
fix: exit cleanly on fail and still push aritfacts (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
daigotanaka authored Jan 4, 2021
1 parent 4b98609 commit bc76f60
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions handoff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ def _run_task_subcommand(
LOGGER.info("Job started at " + str(start))

# Run the command
commands[command](config, **kwargs)
exit_code = 0
try:
commands[command](config, **kwargs)
except Exception as e:
LOGGER.error(str(e))
exit_code = 1

end = datetime.datetime.utcnow()
LOGGER.info("Job ended at " + str(end))
Expand All @@ -187,7 +192,9 @@ def _run_task_subcommand(

os.chdir(prev_wd)

if push_artifacts:
push_artifacts_on_fail = config.get("deploy", {}).get(
"push_artifacts_on_fail", True)
if push_artifacts and (exit_code == 0 or push_artifacts_on_fail):
if not state.get_env(BUCKET):
raise Exception("Cannot push artifacts. BUCKET environment" +
"variable is not set")
Expand Down

0 comments on commit bc76f60

Please sign in to comment.