Merge pull request #4436 from jbradberry/webhook-receivers

Webhook receivers

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot]
2019-10-03 22:23:22 +00:00
committed by GitHub
51 changed files with 2161 additions and 118 deletions

View File

@@ -86,6 +86,8 @@ class JobTemplate(
'vault_credential',
'verbosity',
'job_slice_count',
'webhook_service',
'webhook_credential',
'scm_branch')
update_payload(payload, optional_fields, kwargs)
@@ -102,6 +104,15 @@ class JobTemplate(
payload.update(inventory=kwargs.get('inventory').id)
if kwargs.get('credential'):
payload.update(credential=kwargs.get('credential').id)
if kwargs.get('webhook_credential'):
webhook_cred = kwargs.get('webhook_credential')
if isinstance(webhook_cred, int):
payload.update(webhook_credential=int(webhook_cred))
elif hasattr(webhook_cred, 'id'):
payload.update(webhook_credential=webhook_cred.id)
else:
raise AttributeError("Webhook credential must either be integer of pkid or Credential object")
return payload
def add_label(self, label):

View File

@@ -36,9 +36,15 @@ class WorkflowJobTemplate(HasCopy, HasCreate, HasNotifications, HasSurvey, Unifi
optional_fields = (
"allow_simultaneous",
"ask_variables_on_launch", "ask_inventory_on_launch", "ask_scm_branch_on_launch", "ask_limit_on_launch",
"limit", "scm_branch",
"survey_enabled"
"ask_variables_on_launch",
"ask_inventory_on_launch",
"ask_scm_branch_on_launch",
"ask_limit_on_launch",
"limit",
"scm_branch",
"survey_enabled",
"webhook_service",
"webhook_credential",
)
update_payload(payload, optional_fields, kwargs)
@@ -54,6 +60,15 @@ class WorkflowJobTemplate(HasCopy, HasCreate, HasNotifications, HasSurvey, Unifi
if kwargs.get('inventory'):
payload.inventory = kwargs.get('inventory').id
if kwargs.get('webhook_credential'):
webhook_cred = kwargs.get('webhook_credential')
if isinstance(webhook_cred, int):
payload.update(webhook_credential=int(webhook_cred))
elif hasattr(webhook_cred, 'id'):
payload.update(webhook_credential=webhook_cred.id)
else:
raise AttributeError("Webhook credential must either be integer of pkid or Credential object")
return payload
def create_payload(self, name='', description='', organization=None, **kwargs):