From 2eaeffac6da3439e77d551c074302add4bab7c9f Mon Sep 17 00:00:00 2001 From: Rushi Vishavadia Date: Wed, 11 Sep 2024 17:50:59 +0530 Subject: [PATCH] Sent 'text' attribute for slack postMessage --- scripts/cleanup.sh | 2 +- scripts/release.sh | 3 +++ src/handlers/PipelineUpdateHandler.js | 8 +++++--- 3 files changed, 9 insertions(+), 4 deletions(-) mode change 100644 => 100755 scripts/cleanup.sh diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh old mode 100644 new mode 100755 index f7dd190..64310a2 --- a/scripts/cleanup.sh +++ b/scripts/cleanup.sh @@ -4,4 +4,4 @@ echo -e "\nRemoving all containers" docker rm "$(docker ps -a -q)" echo -e "\nRemoving all images" -docker image rm "$(docker images -a -q)" +docker image prune -a diff --git a/scripts/release.sh b/scripts/release.sh index 7ac73cd..9c27f84 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -16,6 +16,9 @@ docker stop $CONTAINER_NAME echo -e "\n\033[32mStarting ${CONTAINER_NAME}\033[0m" sleep 5 docker run --name $CONTAINER_NAME --rm -d -p 6000:6000 $IMAGE_NAME + +# Wait a little to ensure the container has not exited +sleep 5 echo -e "\n$(docker ps -a)" echo -e "\nRun 'docker logs -f ${CONTAINER_NAME}' to show logs\n" diff --git a/src/handlers/PipelineUpdateHandler.js b/src/handlers/PipelineUpdateHandler.js index d3d1518..a76d64d 100644 --- a/src/handlers/PipelineUpdateHandler.js +++ b/src/handlers/PipelineUpdateHandler.js @@ -129,13 +129,15 @@ class PipelineUpdateHandler extends Handler { const notification = await new PipelineFailedNotification(pipeline, user).toJSON(); const title = notification ? notification.attachments?.[0]?.pretext ?? "N/A" : "N/A"; - await this.app.client.chat.postMessage({ + const payload = { token: config.get("slack.token"), channel: user.id, title, ...notification, - }); - console.log(JSON.stringify(notification, null, 2)); + }; + const response = await this.app.client.chat.postMessage(payload); + console.log(JSON.stringify(payload, null, 2)); + console.log(response); } async getChannelByEmail(email) {