Handle missing bbuilder-tasks files better

This commit is contained in:
Joshua Boniface 2021-10-31 01:41:52 -04:00
parent 430cf8fcf9
commit 8cc1067ed3
1 changed files with 7 additions and 5 deletions

View File

@ -99,11 +99,13 @@ def clone_repository(clone_url):
def parse_config(event, event_action): def parse_config(event, event_action):
print(f'Parsing config from ".bbuilder-tasks.yaml"...') print(f'Parsing config from ".bbuilder-tasks.yaml"...')
try:
with open('.bbuilder-tasks.yaml', 'r') as fh: with open('.bbuilder-tasks.yaml', 'r') as fh:
bbuilder_config = yaml.load(fh, Loader=yaml.BaseLoader).get('bbuilder', None) bbuilder_config = yaml.load(fh, Loader=yaml.BaseLoader).get('bbuilder', None)
if bbuilder_config is None: if bbuilder_config is None:
meta = f'FATAL: Repository ".bbuilder-tasks.yaml" does not contain valid bbuilder syntax' raise
except Exception:
meta = f'FATAL: Repository ".bbuilder-tasks.yaml" does not exist or is not valid'
raise TaskFailure(meta) raise TaskFailure(meta)
tasks = bbuilder_config.get(event, []) tasks = bbuilder_config.get(event, [])