Fix bugs with the custom git trigger and make error reporting better
This commit is contained in:
parent
f858caf6cd
commit
de6267700e
2 changed files with 12 additions and 8 deletions
|
@ -991,7 +991,7 @@ class CustomBuildTrigger(BuildTriggerHandler):
|
|||
'required': ['url', 'message', 'date'],
|
||||
},
|
||||
},
|
||||
'required': ['commits', 'ref', 'default_branch'],
|
||||
'required': ['commit', 'ref', 'default_branch'],
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
@ -1005,15 +1005,15 @@ class CustomBuildTrigger(BuildTriggerHandler):
|
|||
try:
|
||||
metadata = json.loads(payload)
|
||||
validate(metadata, self.payload_schema)
|
||||
except:
|
||||
raise InvalidPayloadException()
|
||||
except Exception as e:
|
||||
raise InvalidPayloadException(e.message)
|
||||
return metadata
|
||||
|
||||
def handle_trigger_request(self, request):
|
||||
# Skip if there is no payload.
|
||||
payload = request.get_json()
|
||||
payload = request.data
|
||||
if not payload:
|
||||
raise SkipRequestException()
|
||||
raise InvalidPayloadException()
|
||||
|
||||
logger.debug('Payload %s', payload)
|
||||
|
||||
|
@ -1028,9 +1028,10 @@ class CustomBuildTrigger(BuildTriggerHandler):
|
|||
|
||||
prepared = PreparedBuild(self.trigger)
|
||||
prepared.tags_from_ref(metadata['ref'])
|
||||
prepared.name_from_sha(metadata['commit_sha'])
|
||||
prepared.name_from_sha(metadata['commit'])
|
||||
prepared.subdirectory = config['subdir']
|
||||
prepared.metadata = metadata
|
||||
prepared.is_manual = False
|
||||
|
||||
return prepared
|
||||
|
||||
|
|
|
@ -89,14 +89,17 @@ def build_trigger_webhook(trigger_uuid, **kwargs):
|
|||
try:
|
||||
prepared = handler.handle_trigger_request(request)
|
||||
except ValidationRequestException:
|
||||
logger.debug('Handler reported a validation exception: %s', handler)
|
||||
# This was just a validation request, we don't need to build anything
|
||||
return make_response('Okay')
|
||||
except SkipRequestException:
|
||||
logger.debug('Handler reported to skip the build: %s', handler)
|
||||
# The build was requested to be skipped
|
||||
return make_response('Okay')
|
||||
except InvalidPayloadException:
|
||||
except InvalidPayloadException as ipe:
|
||||
logger.exception('Invalid payload')
|
||||
# The payload was malformed
|
||||
abort(400)
|
||||
abort(400, message=ipe.message)
|
||||
|
||||
pull_robot_name = model.get_pull_robot_name(trigger)
|
||||
repo = model.get_repository(namespace, repository)
|
||||
|
|
Reference in a new issue