From 3f68456b12cd1731cf22b4573e6edd7e1c35a669 Mon Sep 17 00:00:00 2001 From: Asutosh Das Date: Mon, 23 Sep 2024 19:53:17 +0530 Subject: [PATCH] added migration to fix default image in slack notification template (#5890) --- .../288_slack_notification_template.down.sql | 856 ++++++++++++++++++ .../288_slack_notification_template.up.sql | 856 ++++++++++++++++++ 2 files changed, 1712 insertions(+) create mode 100644 scripts/sql/288_slack_notification_template.down.sql create mode 100644 scripts/sql/288_slack_notification_template.up.sql diff --git a/scripts/sql/288_slack_notification_template.down.sql b/scripts/sql/288_slack_notification_template.down.sql new file mode 100644 index 00000000000..2a3b3622398 --- /dev/null +++ b/scripts/sql/288_slack_notification_template.down.sql @@ -0,0 +1,856 @@ +---- update notification template for CI trigger slack +UPDATE notification_templates +set template_payload = '{ + "text": ":arrow_forward: Build pipeline Triggered | {{#ciMaterials}} Branch > {{branch}} {{/ciMaterials}} | Application > {{appName}}", + "blocks": [{ + "type": "section", + "text": { + "type": "mrkdwn", + "text": "\n" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":arrow_forward: *Build Pipeline triggered*\n \n Triggered by {{triggeredBy}}" + }, + "accessory": { + "type": "image", + "image_url": "https://github.com/devtron-labs/notifier/assets/image/img_build_notification.png", + "alt_text": "calendar thumbnail" + } + }, + { + "type": "section", + "fields": [{ + "type": "mrkdwn", + "text": "*Application*\n{{appName}}" + }, + { + "type": "mrkdwn", + "text": "*Pipeline*\n{{pipelineName}}" + } + ] + }, + {{#ciMaterials}} + {{^webhookType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Branch*\n`{{appName}}/{{branch}}`" + }, + { + "type": "mrkdwn", + "text": "*Commit*\n<{{& commitLink}}|{{commit}}>" + } + ] + }, + {{/webhookType}} + {{#webhookType}} + {{#webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n{{webhookData.data.title}}" + }, + { + "type": "mrkdwn", + "text": "*Git URL*\n<{{& webhookData.data.giturl}}|View>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Source Branch*\n{{webhookData.data.sourcebranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Source Commit*\n<{{& webhookData.data.sourcecheckoutlink}}|{{webhookData.data.sourcecheckout}}>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Branch*\n{{webhookData.data.targetbranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Target Commit*\n<{{& webhookData.data.targetcheckoutlink}}|{{webhookData.data.targetcheckout}}>" + } + ] + }, + {{/webhookData.mergedType}} + {{^webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Checkout*\n{{webhookData.data.targetcheckout}}" + } + ] + }, + {{/webhookData.mergedType}} + {{/webhookType}} + {{/ciMaterials}} + { + "type": "actions", + "elements": [{ + "type": "button", + "text": { + "type": "plain_text", + "text": "View Details" + } + {{#buildHistoryLink}} + , + "url": "{{& buildHistoryLink}}" + {{/buildHistoryLink}} + }] + } + ] +}' +where channel_type = 'slack' +and node_type = 'CI' +and event_type_id = 1; + + +---- update notification template for CI success slack +UPDATE notification_templates +set template_payload = '{ + "text": ":tada: Build pipeline Successful | {{#ciMaterials}} Branch > {{branch}} {{/ciMaterials}} | Application > {{appName}}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "\n" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":tada: *Build Pipeline successful*\n \n Triggered by {{triggeredBy}}" + }, + "accessory": { + "type": "image", + "image_url": "https://github.com/devtron-labs/notifier/assets/image/img_build_notification.png", + "alt_text": "calendar thumbnail" + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Application*\n{{appName}}" + }, + { + "type": "mrkdwn", + "text": "*Pipeline*\n{{pipelineName}}" + } + ] + }, + {{#ciMaterials}} + {{^webhookType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Branch*\n`{{appName}}/{{branch}}`" + }, + { + "type": "mrkdwn", + "text": "*Commit*\n<{{& commitLink}}|{{commit}}>" + } + ] + }, + {{/webhookType}} + {{#webhookType}} + {{#webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n{{webhookData.data.title}}" + }, + { + "type": "mrkdwn", + "text": "*Git URL*\n<{{& webhookData.data.giturl}}|View>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Source Branch*\n{{webhookData.data.sourcebranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Source Commit*\n<{{& webhookData.data.sourcecheckoutlink}}|{{webhookData.data.sourcecheckout}}>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Branch*\n{{webhookData.data.targetbranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Target Commit*\n<{{& webhookData.data.targetcheckoutlink}}|{{webhookData.data.targetcheckout}}>" + } + ] + }, + {{/webhookData.mergedType}} + {{^webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Checkout*\n{{webhookData.data.targetcheckout}}" + } + ] + }, + {{/webhookData.mergedType}} + {{/webhookType}} + {{/ciMaterials}} + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "View Details" + } + {{#buildHistoryLink}} + , + "url": "{{& buildHistoryLink}}" + {{/buildHistoryLink}} + } + ] + } + ] +}' +where channel_type = 'slack' +and node_type = 'CI' +and event_type_id = 2; + + + +---- update notification template for CI fail slack +UPDATE notification_templates +set template_payload = '{ + "text": ":x: Build pipeline Failed | {{#ciMaterials}} Branch > {{branch}} {{/ciMaterials}} | Application > {{appName}}", + "blocks": [{ + "type": "section", + "text": { + "type": "mrkdwn", + "text": "\n" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":x: *Build Pipeline failed*\n \n Triggered by {{triggeredBy}}" + }, + "accessory": { + "type": "image", + "image_url": "https://github.com/devtron-labs/notifier/assets/image/img_build_notification.png", + "alt_text": "calendar thumbnail" + } + }, + { + "type": "section", + "fields": [{ + "type": "mrkdwn", + "text": "*Application*\n{{appName}}" + }, + { + "type": "mrkdwn", + "text": "*Pipeline*\n{{pipelineName}}" + } + ] + }, + {{#ciMaterials}} + {{^webhookType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Branch*\n`{{appName}}/{{branch}}`" + }, + { + "type": "mrkdwn", + "text": "*Commit*\n<{{& commitLink}}|{{commit}}>" + } + ] + }, + {{/webhookType}} + {{#webhookType}} + {{#webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n{{webhookData.data.title}}" + }, + { + "type": "mrkdwn", + "text": "*Git URL*\n<{{& webhookData.data.giturl}}|View>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Source Branch*\n{{webhookData.data.sourcebranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Source Commit*\n<{{& webhookData.data.sourcecheckoutlink}}|{{webhookData.data.sourcecheckout}}>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Branch*\n{{webhookData.data.targetbranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Target Commit*\n<{{& webhookData.data.targetcheckoutlink}}|{{webhookData.data.targetcheckout}}>" + } + ] + }, + {{/webhookData.mergedType}} + {{^webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Checkout*\n{{webhookData.data.targetcheckout}}" + } + ] + }, + {{/webhookData.mergedType}} + {{/webhookType}} + {{/ciMaterials}} + { + "type": "actions", + "elements": [{ + "type": "button", + "text": { + "type": "plain_text", + "text": "View Details" + } + {{#buildHistoryLink}} + , + "url": "{{& buildHistoryLink}}" + {{/buildHistoryLink}} + }] + } + ] +}' +where channel_type = 'slack' +and node_type = 'CI' +and event_type_id = 3; + + +---- update notification template for CD trigger slack +UPDATE notification_templates +set template_payload = '{ + "text": ":arrow_forward: Deployment pipeline Triggered | {{#ciMaterials}} Branch > {{branch}} {{/ciMaterials}} | Application > {{appName}}", + "blocks": [{ + "type": "section", + "text": { + "type": "mrkdwn", + "text": "\n" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":arrow_forward: *Deployment Pipeline triggered on {{envName}}*\n \n by {{triggeredBy}}" + }, + "accessory": { + "type": "image", + "image_url":"https://github.com/devtron-labs/notifier/assets/image/img_deployment_notification.png", + "alt_text": "Deploy Pipeline Triggered" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "fields": [{ + "type": "mrkdwn", + "text": "*Application*\n{{appName}}\n*Pipeline*\n{{pipelineName}}" + }, + { + "type": "mrkdwn", + "text": "*Environment*\n{{envName}}\n*Stage*\n{{stage}}" + } + ] + }, + {{#ciMaterials}} + {{^webhookType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Branch*\n`{{appName}}/{{branch}}`" + }, + { + "type": "mrkdwn", + "text": "*Commit*\n<{{& commitLink}}|{{commit}}>" + } + ] + }, + {{/webhookType}} + {{#webhookType}} + {{#webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n{{webhookData.data.title}}" + }, + { + "type": "mrkdwn", + "text": "*Git URL*\n<{{& webhookData.data.giturl}}|View>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Source Branch*\n{{webhookData.data.sourcebranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Source Commit*\n<{{& webhookData.data.sourcecheckoutlink}}|{{webhookData.data.sourcecheckout}}>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Branch*\n{{webhookData.data.targetbranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Target Commit*\n<{{& webhookData.data.targetcheckoutlink}}|{{webhookData.data.targetcheckout}}>" + } + ] + }, + {{/webhookData.mergedType}} + {{^webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Checkout*\n{{webhookData.data.targetcheckout}}" + } + ] + }, + {{/webhookData.mergedType}} + {{/webhookType}} + {{/ciMaterials}} + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Docker Image*\n`{{dockerImg}}`" + } + }, + { + "type": "actions", + "elements": [{ + "type": "button", + "text": { + "type": "plain_text", + "text": "View Pipeline", + "emoji": true + } + {{#deploymentHistoryLink}} + , + "url": "{{& deploymentHistoryLink}}" + {{/deploymentHistoryLink}} + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "App details", + "emoji": true + } + {{#appDetailsLink}} + , + "url": "{{& appDetailsLink}}" + {{/appDetailsLink}} + } + ] + } + ] +}' +where channel_type = 'slack' +and node_type = 'CD' +and event_type_id = 1; + + + +---- update notification template for CD success slack +UPDATE notification_templates +set template_payload = '{ + "text": ":tada: Deployment pipeline Successful | {{#ciMaterials}} Branch > {{branch}} {{/ciMaterials}} | Application > {{appName}}", + "blocks": [{ + "type": "section", + "text": { + "type": "mrkdwn", + "text": "\n" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":tada: *Deployment Pipeline successful on {{envName}}*\n \n by {{triggeredBy}}" + }, + "accessory": { + "type": "image", + "image_url":"https://github.com/devtron-labs/notifier/assets/image/img_deployment_notification.png", + "alt_text": "calendar thumbnail" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "fields": [{ + "type": "mrkdwn", + "text": "*Application*\n{{appName}}\n*Pipeline*\n{{pipelineName}}" + }, + { + "type": "mrkdwn", + "text": "*Environment*\n{{envName}}\n*Stage*\n{{stage}}" + } + ] + }, + {{#ciMaterials}} + {{^webhookType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Branch*\n`{{appName}}/{{branch}}`" + }, + { + "type": "mrkdwn", + "text": "*Commit*\n<{{& commitLink}}|{{commit}}>" + } + ] + }, + {{/webhookType}} + {{#webhookType}} + {{#webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n{{webhookData.data.title}}" + }, + { + "type": "mrkdwn", + "text": "*Git URL*\n<{{& webhookData.data.giturl}}|View>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Source Branch*\n{{webhookData.data.sourcebranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Source Commit*\n<{{& webhookData.data.sourcecheckoutlink}}|{{webhookData.data.sourcecheckout}}>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Branch*\n{{webhookData.data.targetbranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Target Commit*\n<{{& webhookData.data.targetcheckoutlink}}|{{webhookData.data.targetcheckout}}>" + } + ] + }, + {{/webhookData.mergedType}} + {{^webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Checkout*\n{{webhookData.data.targetcheckout}}" + } + ] + }, + {{/webhookData.mergedType}} + {{/webhookType}} + {{/ciMaterials}} + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Docker Image*\n`{{dockerImg}}`" + } + }, + { + "type": "actions", + "elements": [{ + "type": "button", + "text": { + "type": "plain_text", + "text": "View Pipeline", + "emoji": true + } + {{#deploymentHistoryLink}} + , + "url": "{{& deploymentHistoryLink}}" + {{/deploymentHistoryLink}} + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "App details", + "emoji": true + } + {{#appDetailsLink}} + , + "url": "{{& appDetailsLink}}" + {{/appDetailsLink}} + } + ] + } + ] +}' +where channel_type = 'slack' +and node_type = 'CD' +and event_type_id = 2; + + +---- update notification template for CD fail slack +UPDATE notification_templates +set template_payload = '{ + "text": ":x: Deployment pipeline Failed | {{#ciMaterials}} Branch > {{branch}} {{/ciMaterials}} | Application > {{appName}}", + "blocks": [{ + "type": "section", + "text": { + "type": "mrkdwn", + "text": "\n" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":x: *Deployment Pipeline failed on {{envName}}*\n \n by {{triggeredBy}}" + }, + "accessory": { + "type": "image", + "image_url":"https://github.com/devtron-labs/notifier/assets/image/img_deployment_notification.png", + "alt_text": "calendar thumbnail" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "fields": [{ + "type": "mrkdwn", + "text": "*Application*\n{{appName}}\n*Pipeline*\n{{pipelineName}}" + }, + { + "type": "mrkdwn", + "text": "*Environment*\n{{envName}}\n*Stage*\n{{stage}}" + } + ] + }, + {{#ciMaterials}} + {{^webhookType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Branch*\n`{{appName}}/{{branch}}`" + }, + { + "type": "mrkdwn", + "text": "*Commit*\n<{{& commitLink}}|{{commit}}>" + } + ] + }, + {{/webhookType}} + {{#webhookType}} + {{#webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n{{webhookData.data.title}}" + }, + { + "type": "mrkdwn", + "text": "*Git URL*\n<{{& webhookData.data.giturl}}|View>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Source Branch*\n{{webhookData.data.sourcebranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Source Commit*\n<{{& webhookData.data.sourcecheckoutlink}}|{{webhookData.data.sourcecheckout}}>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Branch*\n{{webhookData.data.targetbranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Target Commit*\n<{{& webhookData.data.targetcheckoutlink}}|{{webhookData.data.targetcheckout}}>" + } + ] + }, + {{/webhookData.mergedType}} + {{^webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Checkout*\n{{webhookData.data.targetcheckout}}" + } + ] + }, + {{/webhookData.mergedType}} + {{/webhookType}} + {{/ciMaterials}} + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Docker Image*\n`{{dockerImg}}`" + } + }, + { + "type": "actions", + "elements": [{ + "type": "button", + "text": { + "type": "plain_text", + "text": "View Pipeline", + "emoji": true + } + {{#deploymentHistoryLink}} + , + "url": "{{& deploymentHistoryLink}}" + {{/deploymentHistoryLink}} + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "App details", + "emoji": true + } + {{#appDetailsLink}} + , + "url": "{{& appDetailsLink}}" + {{/appDetailsLink}} + } + ] + } + ] +}' +where channel_type = 'slack' +and node_type = 'CD' +and event_type_id = 3; \ No newline at end of file diff --git a/scripts/sql/288_slack_notification_template.up.sql b/scripts/sql/288_slack_notification_template.up.sql new file mode 100644 index 00000000000..ca69a39307d --- /dev/null +++ b/scripts/sql/288_slack_notification_template.up.sql @@ -0,0 +1,856 @@ +---- update notification template for CI trigger slack +UPDATE notification_templates +set template_payload = '{ + "text": ":arrow_forward: Build pipeline Triggered | {{#ciMaterials}} Branch > {{branch}} {{/ciMaterials}} | Application > {{appName}}", + "blocks": [{ + "type": "section", + "text": { + "type": "mrkdwn", + "text": "\n" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":arrow_forward: *Build Pipeline triggered*\n \n Triggered by {{triggeredBy}}" + }, + "accessory": { + "type": "image", + "image_url": "https://cdn.devtron.ai/images/img-build-notification.png ", + "alt_text": "calendar thumbnail" + } + }, + { + "type": "section", + "fields": [{ + "type": "mrkdwn", + "text": "*Application*\n{{appName}}" + }, + { + "type": "mrkdwn", + "text": "*Pipeline*\n{{pipelineName}}" + } + ] + }, + {{#ciMaterials}} + {{^webhookType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Branch*\n`{{appName}}/{{branch}}`" + }, + { + "type": "mrkdwn", + "text": "*Commit*\n<{{& commitLink}}|{{commit}}>" + } + ] + }, + {{/webhookType}} + {{#webhookType}} + {{#webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n{{webhookData.data.title}}" + }, + { + "type": "mrkdwn", + "text": "*Git URL*\n<{{& webhookData.data.giturl}}|View>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Source Branch*\n{{webhookData.data.sourcebranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Source Commit*\n<{{& webhookData.data.sourcecheckoutlink}}|{{webhookData.data.sourcecheckout}}>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Branch*\n{{webhookData.data.targetbranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Target Commit*\n<{{& webhookData.data.targetcheckoutlink}}|{{webhookData.data.targetcheckout}}>" + } + ] + }, + {{/webhookData.mergedType}} + {{^webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Checkout*\n{{webhookData.data.targetcheckout}}" + } + ] + }, + {{/webhookData.mergedType}} + {{/webhookType}} + {{/ciMaterials}} + { + "type": "actions", + "elements": [{ + "type": "button", + "text": { + "type": "plain_text", + "text": "View Details" + } + {{#buildHistoryLink}} + , + "url": "{{& buildHistoryLink}}" + {{/buildHistoryLink}} + }] + } + ] +}' +where channel_type = 'slack' +and node_type = 'CI' +and event_type_id = 1; + + +---- update notification template for CI success slack +UPDATE notification_templates +set template_payload = '{ + "text": ":tada: Build pipeline Successful | {{#ciMaterials}} Branch > {{branch}} {{/ciMaterials}} | Application > {{appName}}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "\n" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":tada: *Build Pipeline successful*\n \n Triggered by {{triggeredBy}}" + }, + "accessory": { + "type": "image", + "image_url": "https://cdn.devtron.ai/images/img-build-notification.png ", + "alt_text": "calendar thumbnail" + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Application*\n{{appName}}" + }, + { + "type": "mrkdwn", + "text": "*Pipeline*\n{{pipelineName}}" + } + ] + }, + {{#ciMaterials}} + {{^webhookType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Branch*\n`{{appName}}/{{branch}}`" + }, + { + "type": "mrkdwn", + "text": "*Commit*\n<{{& commitLink}}|{{commit}}>" + } + ] + }, + {{/webhookType}} + {{#webhookType}} + {{#webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n{{webhookData.data.title}}" + }, + { + "type": "mrkdwn", + "text": "*Git URL*\n<{{& webhookData.data.giturl}}|View>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Source Branch*\n{{webhookData.data.sourcebranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Source Commit*\n<{{& webhookData.data.sourcecheckoutlink}}|{{webhookData.data.sourcecheckout}}>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Branch*\n{{webhookData.data.targetbranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Target Commit*\n<{{& webhookData.data.targetcheckoutlink}}|{{webhookData.data.targetcheckout}}>" + } + ] + }, + {{/webhookData.mergedType}} + {{^webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Checkout*\n{{webhookData.data.targetcheckout}}" + } + ] + }, + {{/webhookData.mergedType}} + {{/webhookType}} + {{/ciMaterials}} + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "View Details" + } + {{#buildHistoryLink}} + , + "url": "{{& buildHistoryLink}}" + {{/buildHistoryLink}} + } + ] + } + ] +}' +where channel_type = 'slack' +and node_type = 'CI' +and event_type_id = 2; + + + +---- update notification template for CI fail slack +UPDATE notification_templates +set template_payload = '{ + "text": ":x: Build pipeline Failed | {{#ciMaterials}} Branch > {{branch}} {{/ciMaterials}} | Application > {{appName}}", + "blocks": [{ + "type": "section", + "text": { + "type": "mrkdwn", + "text": "\n" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":x: *Build Pipeline failed*\n \n Triggered by {{triggeredBy}}" + }, + "accessory": { + "type": "image", + "image_url": "https://cdn.devtron.ai/images/img-build-notification.png ", + "alt_text": "calendar thumbnail" + } + }, + { + "type": "section", + "fields": [{ + "type": "mrkdwn", + "text": "*Application*\n{{appName}}" + }, + { + "type": "mrkdwn", + "text": "*Pipeline*\n{{pipelineName}}" + } + ] + }, + {{#ciMaterials}} + {{^webhookType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Branch*\n`{{appName}}/{{branch}}`" + }, + { + "type": "mrkdwn", + "text": "*Commit*\n<{{& commitLink}}|{{commit}}>" + } + ] + }, + {{/webhookType}} + {{#webhookType}} + {{#webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n{{webhookData.data.title}}" + }, + { + "type": "mrkdwn", + "text": "*Git URL*\n<{{& webhookData.data.giturl}}|View>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Source Branch*\n{{webhookData.data.sourcebranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Source Commit*\n<{{& webhookData.data.sourcecheckoutlink}}|{{webhookData.data.sourcecheckout}}>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Branch*\n{{webhookData.data.targetbranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Target Commit*\n<{{& webhookData.data.targetcheckoutlink}}|{{webhookData.data.targetcheckout}}>" + } + ] + }, + {{/webhookData.mergedType}} + {{^webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Checkout*\n{{webhookData.data.targetcheckout}}" + } + ] + }, + {{/webhookData.mergedType}} + {{/webhookType}} + {{/ciMaterials}} + { + "type": "actions", + "elements": [{ + "type": "button", + "text": { + "type": "plain_text", + "text": "View Details" + } + {{#buildHistoryLink}} + , + "url": "{{& buildHistoryLink}}" + {{/buildHistoryLink}} + }] + } + ] +}' +where channel_type = 'slack' +and node_type = 'CI' +and event_type_id = 3; + + +---- update notification template for CD trigger slack +UPDATE notification_templates +set template_payload = '{ + "text": ":arrow_forward: Deployment pipeline Triggered | {{#ciMaterials}} Branch > {{branch}} {{/ciMaterials}} | Application > {{appName}}", + "blocks": [{ + "type": "section", + "text": { + "type": "mrkdwn", + "text": "\n" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":arrow_forward: *Deployment Pipeline triggered on {{envName}}*\n \n by {{triggeredBy}}" + }, + "accessory": { + "type": "image", + "image_url":"https://cdn.devtron.ai/images/img-deploy-notification.png", + "alt_text": "Deploy Pipeline Triggered" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "fields": [{ + "type": "mrkdwn", + "text": "*Application*\n{{appName}}\n*Pipeline*\n{{pipelineName}}" + }, + { + "type": "mrkdwn", + "text": "*Environment*\n{{envName}}\n*Stage*\n{{stage}}" + } + ] + }, + {{#ciMaterials}} + {{^webhookType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Branch*\n`{{appName}}/{{branch}}`" + }, + { + "type": "mrkdwn", + "text": "*Commit*\n<{{& commitLink}}|{{commit}}>" + } + ] + }, + {{/webhookType}} + {{#webhookType}} + {{#webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n{{webhookData.data.title}}" + }, + { + "type": "mrkdwn", + "text": "*Git URL*\n<{{& webhookData.data.giturl}}|View>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Source Branch*\n{{webhookData.data.sourcebranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Source Commit*\n<{{& webhookData.data.sourcecheckoutlink}}|{{webhookData.data.sourcecheckout}}>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Branch*\n{{webhookData.data.targetbranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Target Commit*\n<{{& webhookData.data.targetcheckoutlink}}|{{webhookData.data.targetcheckout}}>" + } + ] + }, + {{/webhookData.mergedType}} + {{^webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Checkout*\n{{webhookData.data.targetcheckout}}" + } + ] + }, + {{/webhookData.mergedType}} + {{/webhookType}} + {{/ciMaterials}} + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Docker Image*\n`{{dockerImg}}`" + } + }, + { + "type": "actions", + "elements": [{ + "type": "button", + "text": { + "type": "plain_text", + "text": "View Pipeline", + "emoji": true + } + {{#deploymentHistoryLink}} + , + "url": "{{& deploymentHistoryLink}}" + {{/deploymentHistoryLink}} + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "App details", + "emoji": true + } + {{#appDetailsLink}} + , + "url": "{{& appDetailsLink}}" + {{/appDetailsLink}} + } + ] + } + ] +}' +where channel_type = 'slack' +and node_type = 'CD' +and event_type_id = 1; + + + +---- update notification template for CD success slack +UPDATE notification_templates +set template_payload = '{ + "text": ":tada: Deployment pipeline Successful | {{#ciMaterials}} Branch > {{branch}} {{/ciMaterials}} | Application > {{appName}}", + "blocks": [{ + "type": "section", + "text": { + "type": "mrkdwn", + "text": "\n" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":tada: *Deployment Pipeline successful on {{envName}}*\n \n by {{triggeredBy}}" + }, + "accessory": { + "type": "image", + "image_url":"https://cdn.devtron.ai/images/img-deploy-notification.png", + "alt_text": "calendar thumbnail" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "fields": [{ + "type": "mrkdwn", + "text": "*Application*\n{{appName}}\n*Pipeline*\n{{pipelineName}}" + }, + { + "type": "mrkdwn", + "text": "*Environment*\n{{envName}}\n*Stage*\n{{stage}}" + } + ] + }, + {{#ciMaterials}} + {{^webhookType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Branch*\n`{{appName}}/{{branch}}`" + }, + { + "type": "mrkdwn", + "text": "*Commit*\n<{{& commitLink}}|{{commit}}>" + } + ] + }, + {{/webhookType}} + {{#webhookType}} + {{#webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n{{webhookData.data.title}}" + }, + { + "type": "mrkdwn", + "text": "*Git URL*\n<{{& webhookData.data.giturl}}|View>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Source Branch*\n{{webhookData.data.sourcebranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Source Commit*\n<{{& webhookData.data.sourcecheckoutlink}}|{{webhookData.data.sourcecheckout}}>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Branch*\n{{webhookData.data.targetbranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Target Commit*\n<{{& webhookData.data.targetcheckoutlink}}|{{webhookData.data.targetcheckout}}>" + } + ] + }, + {{/webhookData.mergedType}} + {{^webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Checkout*\n{{webhookData.data.targetcheckout}}" + } + ] + }, + {{/webhookData.mergedType}} + {{/webhookType}} + {{/ciMaterials}} + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Docker Image*\n`{{dockerImg}}`" + } + }, + { + "type": "actions", + "elements": [{ + "type": "button", + "text": { + "type": "plain_text", + "text": "View Pipeline", + "emoji": true + } + {{#deploymentHistoryLink}} + , + "url": "{{& deploymentHistoryLink}}" + {{/deploymentHistoryLink}} + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "App details", + "emoji": true + } + {{#appDetailsLink}} + , + "url": "{{& appDetailsLink}}" + {{/appDetailsLink}} + } + ] + } + ] +}' +where channel_type = 'slack' +and node_type = 'CD' +and event_type_id = 2; + + +---- update notification template for CD fail slack +UPDATE notification_templates +set template_payload = '{ + "text": ":x: Deployment pipeline Failed | {{#ciMaterials}} Branch > {{branch}} {{/ciMaterials}} | Application > {{appName}}", + "blocks": [{ + "type": "section", + "text": { + "type": "mrkdwn", + "text": "\n" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":x: *Deployment Pipeline failed on {{envName}}*\n \n by {{triggeredBy}}" + }, + "accessory": { + "type": "image", + "image_url":"https://cdn.devtron.ai/images/img-deploy-notification.png", + "alt_text": "calendar thumbnail" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "fields": [{ + "type": "mrkdwn", + "text": "*Application*\n{{appName}}\n*Pipeline*\n{{pipelineName}}" + }, + { + "type": "mrkdwn", + "text": "*Environment*\n{{envName}}\n*Stage*\n{{stage}}" + } + ] + }, + {{#ciMaterials}} + {{^webhookType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Branch*\n`{{appName}}/{{branch}}`" + }, + { + "type": "mrkdwn", + "text": "*Commit*\n<{{& commitLink}}|{{commit}}>" + } + ] + }, + {{/webhookType}} + {{#webhookType}} + {{#webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Title*\n{{webhookData.data.title}}" + }, + { + "type": "mrkdwn", + "text": "*Git URL*\n<{{& webhookData.data.giturl}}|View>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Source Branch*\n{{webhookData.data.sourcebranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Source Commit*\n<{{& webhookData.data.sourcecheckoutlink}}|{{webhookData.data.sourcecheckout}}>" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Branch*\n{{webhookData.data.targetbranchname}}" + }, + { + "type": "mrkdwn", + "text": "*Target Commit*\n<{{& webhookData.data.targetcheckoutlink}}|{{webhookData.data.targetcheckout}}>" + } + ] + }, + {{/webhookData.mergedType}} + {{^webhookData.mergedType}} + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Target Checkout*\n{{webhookData.data.targetcheckout}}" + } + ] + }, + {{/webhookData.mergedType}} + {{/webhookType}} + {{/ciMaterials}} + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Docker Image*\n`{{dockerImg}}`" + } + }, + { + "type": "actions", + "elements": [{ + "type": "button", + "text": { + "type": "plain_text", + "text": "View Pipeline", + "emoji": true + } + {{#deploymentHistoryLink}} + , + "url": "{{& deploymentHistoryLink}}" + {{/deploymentHistoryLink}} + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "App details", + "emoji": true + } + {{#appDetailsLink}} + , + "url": "{{& appDetailsLink}}" + {{/appDetailsLink}} + } + ] + } + ] +}' +where channel_type = 'slack' +and node_type = 'CD' +and event_type_id = 3; \ No newline at end of file