Update CI/CD Pipline, Add notify in TG
This commit is contained in:
+33
-1
@@ -6,6 +6,7 @@ stages:
|
||||
- tests
|
||||
- build-and-push
|
||||
- deploy
|
||||
- notify
|
||||
|
||||
tests_job1:
|
||||
stage: tests
|
||||
@@ -47,4 +48,35 @@ deploy_to_server:
|
||||
- ansible-galaxy collection install community.docker
|
||||
script:
|
||||
- cd auto-deployment/
|
||||
- ansible-playbook -i inventory.ini A_deploy.yml
|
||||
- ansible-playbook -i inventory.ini A_deploy.yml
|
||||
|
||||
variables:
|
||||
MSG_SUCCESS: "✅ <b>Успех!</b> Пайплайн проекта <b>$CI_PROJECT_NAME</b> завершен.\nВетка: $CI_COMMIT_REF_NAME\nКоммит: $CI_COMMIT_MESSAGE"
|
||||
MSG_FAILURE: "❌ <b>Ошибка!</b> Пайплайн проекта <b>$CI_PROJECT_NAME</b> упал.\nВетка: $CI_COMMIT_REF_NAME\n<a href='$CI_PIPELINE_URL'>Смотреть логи пайплайна</a>"
|
||||
|
||||
.notify_telegram:
|
||||
stage: .post
|
||||
image: curlimages/curl:latest
|
||||
script:
|
||||
- |
|
||||
curl -s -X POST "https://api.telegram.org/bot$ALERT_TG_BOT/sendMessage" \
|
||||
-d chat_id="$ADMIN_ID_TG" \
|
||||
-d text="$MESSAGE" \
|
||||
-d parse_mode="HTML" \
|
||||
-d disable_web_page_preview="true"
|
||||
|
||||
# Успех
|
||||
notify_success:
|
||||
extends: .notify_telegram
|
||||
variables:
|
||||
MESSAGE: $MSG_SUCCESS
|
||||
when: on_success
|
||||
|
||||
# Провал
|
||||
notify_failure:
|
||||
extends: .notify_telegram
|
||||
variables:
|
||||
MESSAGE: $MSG_FAILURE
|
||||
when: on_failure
|
||||
|
||||
|
||||
Reference in New Issue
Block a user