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:
|
branch:
|
||||||
- prod
|
- prod
|
||||||
|
|
||||||
- name: slack
|
- name: google-chat
|
||||||
image: plugins/slack
|
image: badouralix/curl-jq
|
||||||
settings:
|
failure: ignore
|
||||||
webhook: https://hooks.slack.com/services/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
|
environment:
|
||||||
channel: modules-communs
|
GOOGLE_CHAT_WEBHOOK: "https://chat.googleapis.com/v1/spaces/AAQAGPSk8N0/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=QA6EDa74Bv-zWs7NiWrq54npANfaUtgqQBjOd35ZRCs"
|
||||||
template: >
|
NOTIFICATION_CONTEXT: "Build"
|
||||||
{{#success build.status}}
|
NOTIFICATION_TARGET_LABEL: "Voir le dépôt"
|
||||||
:white_check_mark: Déploiement <${DRONE_BUILD_LINK}|#${DRONE_BUILD_NUMBER}>. Beau travail, ${DRONE_COMMIT_AUTHOR_NAME} !
|
NOTIFICATION_TARGET_URL: "https://git.nwb.fr/modules-communs-php/multi-downloader-client"
|
||||||
{{else}}
|
commands:
|
||||||
:x: Déploiement <${DRONE_BUILD_LINK}|#${DRONE_BUILD_NUMBER}> c'est un échec, ${DRONE_COMMIT_AUTHOR_NAME}.
|
- |
|
||||||
{{/success}}
|
set -eu
|
||||||
|
jq -n '
|
||||||
Repository : <${DRONE_REPO_LINK}|${DRONE_REPO_NAME}> depuis branche ${DRONE_BRANCH}
|
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:
|
when:
|
||||||
status:
|
status:
|
||||||
- failure
|
- failure
|
||||||
|
|||||||
@@ -3,3 +3,4 @@
|
|||||||
vendor
|
vendor
|
||||||
composer.lock
|
composer.lock
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
Icon?
|
||||||
Reference in new issue
Block a user