diff --git a/app/scripts/modules/core/src/pipeline/config/stages/webhook/webhookExecutionDetails.controller.ts b/app/scripts/modules/core/src/pipeline/config/stages/webhook/webhookExecutionDetails.controller.ts index 99e368eae69..086c514863e 100644 --- a/app/scripts/modules/core/src/pipeline/config/stages/webhook/webhookExecutionDetails.controller.ts +++ b/app/scripts/modules/core/src/pipeline/config/stages/webhook/webhookExecutionDetails.controller.ts @@ -16,6 +16,7 @@ export class WebhookExecutionDetailsCtrl implements IController { public progressMessage: string; public body: string; public stage: any; + public payload: string; constructor( private $stateParams: StateParams, @@ -33,6 +34,7 @@ export class WebhookExecutionDetailsCtrl implements IController { this.failureMessage = this.getFailureMessage(); this.progressMessage = this.getProgressMessage(); this.body = this.getBodyContent(); + this.payload = JSON.stringify(this.stage.context.payload, null, 2); } private getProgressMessage(): string { @@ -46,7 +48,7 @@ export class WebhookExecutionDetailsCtrl implements IController { const context = this.stage.context || {}, webhook = context.webhook || {}, monitor = webhook.monitor || {}, - error = webhook.error || null; + error = monitor.error || webhook.error || null; if (error) { failureMessage = `Webhook failed: ${error}`; @@ -58,12 +60,21 @@ export class WebhookExecutionDetailsCtrl implements IController { } private getBodyContent(): string { - let body = (this.stage.context && this.stage.context.webhook && this.stage.context.webhook.body) || null; + // If there was a webhook monitor task get the body from it, otherwise get it from webhook + const context = this.stage.context || {}, + webhook = context.webhook || {}, + monitor = webhook.monitor || {}; + + const body = monitor.body || webhook.body || null; // Empty body is only allowed when we haven't started or are running the task. // Otherwise, assume the request completed and didn't yield a body in the response if (!body && this.stage.originalStatus !== 'NOT_STARTED' && this.stage.originalStatus !== 'RUNNING') { - body = ''; + return ''; + } + + if (typeof body === 'object') { + return JSON.stringify(body, null, 2); } return body; diff --git a/app/scripts/modules/core/src/pipeline/config/stages/webhook/webhookExecutionDetails.html b/app/scripts/modules/core/src/pipeline/config/stages/webhook/webhookExecutionDetails.html index 06209ed396c..b011d93d759 100644 --- a/app/scripts/modules/core/src/pipeline/config/stages/webhook/webhookExecutionDetails.html +++ b/app/scripts/modules/core/src/pipeline/config/stages/webhook/webhookExecutionDetails.html @@ -7,8 +7,16 @@
Webhook Stage Configuration
Url
{{ctrl.stage.context.url}}
-
Payload
-
{{ctrl.stage.context.payload}}
+
+ + + Payload +
+
+
{{ctrl.payload}}
+
@@ -33,9 +41,17 @@

Results

Info

Code
-
{{ctrl.stage.context.webhook.statusCodeValue}}
-
Response
-
{{ctrl.body}}
+
{{ctrl.stage.context.webhook.monitor.statusCodeValue || ctrl.stage.context.webhook.statusCodeValue}}
+
+ + + Response +
+
+
{{ctrl.body}}
+