Skip to content

Instantly share code, notes, and snippets.

@alz-ahm
Created October 13, 2019 13:56
Show Gist options
  • Save alz-ahm/6b17058e607cbaf3ff5ccb6bf0c624c2 to your computer and use it in GitHub Desktop.
Save alz-ahm/6b17058e607cbaf3ff5ccb6bf0c624c2 to your computer and use it in GitHub Desktop.
def sendTelegram(message) {
def encodedMessage = URLEncoder.encode(message, "UTF-8")
withCredentials([string(credentialsId: 'telegramToken', variable: 'TOKEN'),
string(credentialsId: 'telegramChatId', variable: 'CHAT_ID')]) {
response = httpRequest (consoleLogResponseBody: true,
contentType: 'APPLICATION_JSON',
httpMode: 'GET',
url: "https://api.telegram.org/bot$TOKEN/sendMessage?text=$encodedMessage&chat_id=$CHAT_ID&disable_web_page_preview=true",
validResponseCodes: '200')
return response
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment