pipeline: eagerly cleanup trees in error case
The `build_stages` method short-circuits and returns early in case any of the stages fail to build and returns None for the tree, and build tree, therefore both of those can immediately cleaned up at that point. For this add a small helper `cleanup` that will call the cleanup method for all supplied arguments, after filtering out None values.
This commit is contained in:
parent
08fc223276
commit
56e0ac7c92
1 changed files with 6 additions and 0 deletions
|
|
@ -17,6 +17,11 @@ RESET = "\033[0m"
|
|||
BOLD = "\033[1m"
|
||||
|
||||
|
||||
def cleanup(*objs):
|
||||
"""Call cleanup method for all objects, filters None values out"""
|
||||
_ = map(lambda o: o.cleanup(), filter(None, objs))
|
||||
|
||||
|
||||
class BuildResult:
|
||||
def __init__(self, origin, returncode, output):
|
||||
self.name = origin.name
|
||||
|
|
@ -285,6 +290,7 @@ class Pipeline:
|
|||
|
||||
results["stages"].append(r.as_dict())
|
||||
if not r.success:
|
||||
cleanup(build_tree, tree)
|
||||
results["success"] = False
|
||||
return results, None, None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue