diff --git a/buildtrigger/triggerutil.py b/buildtrigger/triggerutil.py index 40c1a7bde..b60f38620 100644 --- a/buildtrigger/triggerutil.py +++ b/buildtrigger/triggerutil.py @@ -71,8 +71,11 @@ def find_matching_branches(config, branches): return branches -def should_skip_commit(message): - return '[skip build]' in message or '[build skip]' in message +def should_skip_commit(metadata): + if 'commit_info' in metadata: + message = metadata['commit_info']['message'] + return '[skip build]' in message or '[build skip]' in message + return False def raise_if_skipped_build(prepared_build, config): @@ -93,7 +96,7 @@ def raise_if_skipped_build(prepared_build, config): raise SkipRequestException() # Check the commit message. - if should_skip_commit(prepared_build.metadata['commit_info']['message']): + if should_skip_commit(prepared_build.metadata): logger.debug('Skipping request due to commit message request') raise SkipRequestException()