MODIF - Remplacement de la notification Slack par une notification Google Chat dans le pipeline Drone
continuous-integration/drone/push Build is failing
continuous-integration/drone/push Build is failing
This commit is contained in:
1 parent
6543fadab4
commit
5504d6dfb7
2 files changed
+43
-13
No files matched your search
+42
-13
@@ -38,19 +38,48 @@ steps:
|
||||
branch:
|
||||
- prod
|
||||
|
||||
- name: slack
|
||||
image: plugins/slack
|
||||
settings:
|
||||
webhook: https://hooks.slack.com/services/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
|
||||
channel: modules-communs
|
||||
template: >
|
||||
{{#success build.status}}
|
||||
:white_check_mark: Déploiement <${DRONE_BUILD_LINK}|#${DRONE_BUILD_NUMBER}>. Beau travail, ${DRONE_COMMIT_AUTHOR_NAME} !
|
||||
{{else}}
|
||||
:x: Déploiement <${DRONE_BUILD_LINK}|#${DRONE_BUILD_NUMBER}> c'est un échec, ${DRONE_COMMIT_AUTHOR_NAME}.
|
||||
{{/success}}
|
||||
|
||||
Repository : <${DRONE_REPO_LINK}|${DRONE_REPO_NAME}> depuis branche ${DRONE_BRANCH}
|
||||
- name: google-chat
|
||||
image: badouralix/curl-jq
|
||||
failure: ignore
|
||||
environment:
|
||||
GOOGLE_CHAT_WEBHOOK: "https://chat.googleapis.com/v1/spaces/AAQAGPSk8N0/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=QA6EDa74Bv-zWs7NiWrq54npANfaUtgqQBjOd35ZRCs"
|
||||
NOTIFICATION_CONTEXT: "Build"
|
||||
NOTIFICATION_TARGET_LABEL: "Voir le dépôt"
|
||||
NOTIFICATION_TARGET_URL: "https://git.nwb.fr/modules-communs-php/multi-downloader-client"
|
||||
commands:
|
||||
- |
|
||||
set -eu
|
||||
jq -n '
|
||||
def html: gsub("&"; "&") | gsub("<"; "<") | gsub(">"; ">");
|
||||
(env.DRONE_BUILD_STATUS == "success") as $success |
|
||||
(env.NOTIFICATION_CONTEXT // "Build") as $context |
|
||||
{
|
||||
cardsV2: [{
|
||||
cardId: "drone-notification",
|
||||
card: {
|
||||
header: {
|
||||
title: (if env.NOTIFICATION_PHASE == "start" then "🚀 " + $context + (if $context == "Publication" then " démarrée" else " démarré" end) elif $success then "✅ " + $context + (if $context == "Publication" then " réussie" else " réussi" end) else "❌ " + $context + " en échec" end),
|
||||
subtitle: ((env.DRONE_REPO_NAME // "Projet") + " · build #" + (env.DRONE_BUILD_NUMBER // "?"))
|
||||
},
|
||||
sections: [{
|
||||
widgets: [
|
||||
{decoratedText: {startIcon: {materialIcon: {name: "person"}}, topLabel: "Auteur", text: ((env.DRONE_COMMIT_AUTHOR_NAME // env.DRONE_COMMIT_AUTHOR // "Inconnu") | html)}},
|
||||
{decoratedText: {startIcon: {materialIcon: {name: "account_tree"}}, topLabel: "Branche", text: ((env.DRONE_BRANCH // "Inconnue") | html)}},
|
||||
{decoratedText: {startIcon: {materialIcon: {name: "commit"}}, topLabel: "Commit", text: (((env.DRONE_COMMIT_SHA // "")[0:8] + " : " + (env.DRONE_COMMIT_MESSAGE // "")) | html), wrapText: true}},
|
||||
{buttonList: {buttons: ([
|
||||
{text: env.NOTIFICATION_TARGET_LABEL, onClick: {openLink: {url: env.NOTIFICATION_TARGET_URL}}},
|
||||
{text: "Voir les logs Drone", onClick: {openLink: {url: env.DRONE_BUILD_LINK}}},
|
||||
{text: "Voir le commit", onClick: {openLink: {url: env.DRONE_COMMIT_LINK}}}
|
||||
] | map(select(.onClick.openLink.url != null and .onClick.openLink.url != "")))}}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}]
|
||||
}
|
||||
' > /tmp/google-chat-payload.json
|
||||
curl --fail-with-body --silent --show-error --connect-timeout 10 --max-time 30 \
|
||||
-X POST -H "Content-Type: application/json; charset=UTF-8" \
|
||||
--data-binary @/tmp/google-chat-payload.json "$GOOGLE_CHAT_WEBHOOK"
|
||||
when:
|
||||
status:
|
||||
- failure
|
||||
|
||||
Reference in new issue
Block a user