First stab at implementing token.activate.
This commit is contained in:
parent
d5304f7db0
commit
a6400171b3
3 changed files with 28 additions and 7 deletions
|
@ -47,11 +47,12 @@ class BuildTrigger(object):
|
|||
|
||||
def is_active(self, config):
|
||||
"""
|
||||
Returns True if the current build trigger is active. Inactive means further setup is needed.
|
||||
Returns True if the current build trigger is active. Inactive means further
|
||||
setup is needed.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def activate(self, auth_token, config):
|
||||
def activate(self, trigger_uuid, standard_webhook_url, auth_token, config):
|
||||
"""
|
||||
Activates the trigger for the service, with the given new configuration.
|
||||
"""
|
||||
|
@ -90,9 +91,23 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
def is_active(self, config):
|
||||
return 'build_source' in config and len(config['build_source']) > 0
|
||||
|
||||
def activate(self, auth_token, config):
|
||||
# TODO: Add the callback web hook to the github repository.
|
||||
pass
|
||||
def activate(self, trigger_uuid, standard_webhook_url, auth_token, config):
|
||||
new_build_source = config['build_source']
|
||||
gh_client = self._get_client(auth_token)
|
||||
|
||||
try:
|
||||
to_add_webhook = gh_client.get_repo(new_build_source)
|
||||
|
||||
webhook_config = {
|
||||
'url': standard_webhook_url,
|
||||
'content_type': 'json',
|
||||
}
|
||||
|
||||
to_add_webhook.create_hook('web', webhook_config)
|
||||
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def list_build_sources(self, auth_token):
|
||||
gh_client = self._get_client(auth_token)
|
||||
|
|
Reference in a new issue