Jenkins-Telegram-SendMessage
Create a Pipeline project.



Program
pipeline {
agent any
stages {
stage('Notify Telegram') {
steps {
script {
def chatId = "-1002146311706"
def token = "7150149831:AAEHAf4637njRm5wYoCUd_YTHjaMfxlJA6I"
def message = "Jenkins Alert! : $BUILD_ENV IN $DEPLOY_REGION "
// Windows curl command using bat
bat """
echo "Building in environment: $BUILD_ENV"
echo "Deploying: $DEPLOY_REGION"
curl -s -X POST "https://api.telegram.org/bot${token}/sendMessage" ^
-d chat_id="${chatId}" ^
-d text="${message}"
"""
}
}
}
}
}
After creating the job in post build step