trigger: initial custom git trigger

This commit is contained in:
Jimmy Zelinskie 2015-03-26 16:20:53 -04:00
parent 9c55aca011
commit 998c6007cd
4 changed files with 143 additions and 8 deletions

View file

@ -212,15 +212,12 @@ class BuildTriggerActivate(RepositoryParamResource):
token = model.create_delegate_token(namespace, repository, token_name,
'write')
# Generate an SSH keypair
new_config_dict['public_key'], trigger.private_key = generate_ssh_keypair()
try:
path = url_for('webhooks.build_trigger_webhook', trigger_uuid=trigger.uuid)
authed_url = _prepare_webhook_url(app.config['PREFERRED_URL_SCHEME'], '$token', token.code,
app.config['SERVER_HOSTNAME'], path)
final_config = handler.activate(trigger.uuid, authed_url,
final_config, trigger.private_key = handler.activate(trigger.uuid, authed_url,
trigger.auth_token, new_config_dict)
except TriggerActivationException as exc:
token.delete_instance()
@ -512,3 +509,12 @@ class BuildTriggerSources(RepositoryParamResource):
}
else:
raise Unauthorized()
@resource('/v1/repository/<repopath:repository>/trigger/redirect')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@internal_only
class CustomBuildTriggerRedirect(RepositoryParamResource):
""" Custom verb to properly handle redirecting users using their own custom git hook. """
@nickname('customTriggerRedirect')
def get(self, namespace, repository):
pass