From 1b9932f492e959356118936b9adab09d5e0f1f64 Mon Sep 17 00:00:00 2001 From: Mpho raf Date: Sat, 4 Feb 2023 15:11:02 +0200 Subject: [PATCH] Using curl to send telegrams --- Jenkinsfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a2fbde3..f0370fd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,8 @@ pipeline { agent any + environment { + TELEAPI_KEY = credentials('telegram-token') + } stages { stage('Git-checout') { steps { @@ -22,7 +25,7 @@ pipeline { stage('Quality-gate') { steps { echo "Sonaqube static code analysis passed!!" - sh 'return 0' // change to 1 for testing a failure + sh 'return 1' // change to 1 for testing a failure } } @@ -39,11 +42,11 @@ pipeline { } success { echo "This will run only upon success" - telegramSend(message: '[✅] Build Is a success', chatId: "${env.TELE_CHAT_ID}") + sh 'curl -s -o /dev/null https://api.telegram.org/bot${TELEAPI_KEY}/sendMessage -d chat_id="${TELE_CHAT_ID}" -d text="[✅] Build Is a success"' } failure { echo "This will run/show only if failed" - telegramSend(message: '[❌] Failed to build 😱', chatId: "${env.TELE_CHAT_ID}") + sh 'curl -s -o /dev/null https://api.telegram.org/bot${TELEAPI_KEY}/sendMessage -d chat_id="${TELE_CHAT_ID}" -d text="[❌] Failed to build 😱"' } unstable { echo "This will show only if the was marked as unstable!"