GithubHelp home page GithubHelp logo

jenkinsci / telegram-notifications-plugin Goto Github PK

View Code? Open in Web Editor NEW
72.0 8.0 62.0 69 KB

This plugin allows you to send messages from Jenkins jobs to Telegram chat.

Home Page: https://plugins.jenkins.io/telegram-notifications/

License: MIT License

Java 100.00%
telegram notifications jenkins

telegram-notifications-plugin's Introduction

TeleJenkins Build Status

TeleJenkins Logo

This plugin allows Jenkins to send notifications via telegram bot.


Installation

Build from source

  1. To build a plugin, run mvn install. This will create the file ./target/telegram-notifications.hpi
  2. Manually install plugin to your Jenkins

Download an hpi

  1. Download telegram-notifications-*.hpi release here
  2. Manually install plugin to your Jenkins

Plugin Manager

  1. Go to <your_jenkins>/pluginManager/available
  2. Find and install Telegram Bot

Basic usage

Create bot

  1. Find BotFather in Telegram (@BotFather)
  2. Send /newbot command
  3. Follow the instructions

Global config

  1. Open the Jenkins global config
  2. Paste your bot name and token to according textfields

Subscribe for Jenkins messages

  1. In telegram find your bot and send /start command
  2. Send /sub command

Manage your job

  1. Add a build step and/or a post build step
  2. Fill the message (you can use environment variables and simple Markdown)

Use in Pipeline

telegramSend 'Hello World'

Or, to send the message to some specific chat/channel: telegramSend(message: 'Hello World', chatId: 1234567890)

telegram-notifications-plugin's People

Contributors

afanmatvey avatar alekseiko avatar amezin avatar daniel-beck-bot avatar marfx000 avatar nikitabelonogovbot avatar rpanak-generalbytes avatar sturman avatar voland666 avatar wlad031 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

telegram-notifications-plugin's Issues

Manual approval not working

no users in list
image
just auto aproval working.
/sub command sent sucessfully, bot said "wait for approval from admin"

TelegramToken problems

If you make changes in the settings when the telegram token was saved before. It is either hashed again or another problem and just stops working. It turns out to be fixed only by changing the token with any changes to the settings. The hash in the example has been changed.
Although, judging by the logs, he is just trying to send a hashed token. In a working config, the token is not hashed at all.
Please tell me if you need additional data.

Jenkins 2.248

OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
<?xml version='1.1' encoding='UTF-8'?>
<jenkinsci.plugins.telegrambot.TelegramBotGlobalConfiguration plugin="[email protected]">
  <botStrings class="java.util.Collections$UnmodifiableMap">
    <m>
      <entry>
        <string>command.start</string>
        <string>Start bot</string>
      </entry>
      <entry>
        <string>command.status</string>
        <string>Check your subscribe status</string>
      </entry>
      <entry>
        <string>message.status.approved</string>
        <string>You&apos;ve subscribed and approved for Jenkins messages.</string>
      </entry>
      <entry>
        <string>command.help</string>
        <string>Get help message</string>
      </entry>
      <entry>
        <string>command.sub</string>
        <string>Subscribe for Jenkins messages</string>
      </entry>
      <entry>
        <string>message.noncommand</string>
        <string>Please use /help to get the list of possible commands.</string>
      </entry>
      <entry>
        <string>message.unapproved</string>
        <string>You&apos;ve been unapproved by Jenkins admin.</string>
      </entry>
      <entry>
        <string>message.unsub.success</string>
        <string>You&apos;ve successfully unsubscribed.</string>
      </entry>
      <entry>
        <string>message.unsub.alreadyunsub</string>
        <string>You&apos;ve already unsubscribed.</string>
      </entry>
      <entry>
        <string>message.status.unsubscribed</string>
        <string>You&apos;ve not subscribed for Jenkins messages.</string>
      </entry>
      <entry>
        <string>message.approved</string>
        <string>You&apos;ve been approved by Jenkins admin.</string>
      </entry>
      <entry>
        <string>message.help</string>
        <string>You&apos;re using Jenkins Bot. It can send to you some Jenkins messages.

You can control this bot by sending these commands:
/help - display this message
/sub - subscribe for Jenkins messages
/unsub - unsubscribe from Jenkins messages
/status - get your status</string>
      </entry>
      <entry>
        <string>message.sub.alreadysub</string>
        <string>You&apos;ve already subscribed.</string>
      </entry>
      <entry>
        <string>message.sub.success</string>
        <string>You&apos;ve successfully subscribed. Please, wait for approval from the Jenkins admin.</string>
      </entry>
      <entry>
        <string>message.error</string>
        <string>Some error happened :(</string>
      </entry>
      <entry>
        <string>message.status.unapproved</string>
        <string>You&apos;ve subscribed but not approved for Jenkins messages.</string>
      </entry>
      <entry>
        <string>command.unsub</string>
        <string>Unsubscribe from Jenkins messages</string>
      </entry>
    </m>
  </botStrings>
  <shouldLogToConsole>false</shouldLogToConsole>
  <botToken>TestTestTestTestTestTestTest</botToken>
  <botName>Test_bot</botName>
  <approvalType>MANUAL</approvalType>
  <users>
    <jenkinsci.plugins.telegrambot.users.User>
      <name>User{id=TestTestTest, firstName=&apos;Test&apos;, isBot=false, lastName=&apos;null&apos;, userName=&apos;Test&apos;, languageCode=&apos;eng&apos;}</name>
      <id>Test</id>
      <isApproved>false</isApproved>
    </jenkinsci.plugins.telegrambot.users.User>
    <jenkinsci.plugins.telegrambot.users.User>
      <name>User{id=TestvTest, firstName=&apos;Test&apos;, isBot=false, lastName=&apos;null&apos;, userName=&apos;Test&apos;, languageCode=&apos;eng&apos;}</name>
      <id>Test</id>
      <isApproved>true</isApproved>
    </jenkinsci.plugins.telegrambot.users.User>
  </users>
2020-08-02 03:22:05.554+0000 [id=61]    SEVERE  j.p.t.telegram.TelegramBot#sendMessage: Error while sending the message
java.net.URISyntaxException: Illegal character in path at index 28: https://api.telegram.org/bot{d41d8cd98f00b204e9800998ecf8427e==}/sendmessage
        at java.net.URI$Parser.fail(URI.java:2848)
        at java.net.URI$Parser.checkChars(URI.java:3021)
        at java.net.URI$Parser.parseHierarchical(URI.java:3105)
        at java.net.URI$Parser.parse(URI.java:3053)
        at java.net.URI.<init>(URI.java:588)
        at java.net.URI.create(URI.java:850)
Caused: java.lang.IllegalArgumentException: Illegal character in path at index 28: https://api.telegram.org/bot{AQAAABAAAAAwCHyyeFt7FhnbbwXu/pFua7/Z0CfSvQAK19++c4iry97iH2wFzgYrUfqAz9ves4qzJFTCnUJKZazM08bQz/V0CQ==}/sendmessage
        at java.net.URI.create(URI.java:852)
        at org.apache.http.client.methods.HttpPost.<init>(HttpPost.java:73)
        at jenkinsci.plugins.telegrambot.telegram.TelegramBot.configuredHttpPost(TelegramBot.java:174)
        at jenkinsci.plugins.telegrambot.telegram.TelegramBot.sendMethodRequest(TelegramBot.java:250)
        at jenkinsci.plugins.telegrambot.telegram.TelegramBot.sendApiMethodWithProxy(TelegramBot.java:238)
        at jenkinsci.plugins.telegrambot.telegram.TelegramBot.execute(TelegramBot.java:170)
        at jenkinsci.plugins.telegrambot.telegram.TelegramBot.sendMessage(TelegramBot.java:81)
        at jenkinsci.plugins.telegrambot.telegram.TelegramBot.lambda$sendMessage$0(TelegramBot.java:109)
        at java.lang.Iterable.forEach(Iterable.java:75)
        at jenkinsci.plugins.telegrambot.telegram.TelegramBot.sendMessage(TelegramBot.java:109)
        at jenkinsci.plugins.telegrambot.telegram.TelegramBot.sendMessage(TelegramBot.java:125)
        at jenkinsci.plugins.telegrambot.TelegramBotPublisher.perform(TelegramBotPublisher.java:85)
        at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:112)
        at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
        at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
        at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
        at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
        at hudson.model.Build$BuildExecution.post2(Build.java:186)
        at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
        at hudson.model.Run.execute(Run.java:1905)
        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
        at hudson.model.ResourceController.execute(ResourceController.java:97)
        at hudson.model.Executor.run(Executor.java:428)

Error building from snapshot

  1. download master
  2. unpack
  3. mvn

result:

[WARNING] The POM for org.jenkins-ci.tools:maven-hpi-plugin:jar:3.12 is missing, no dependency information available
Downloading: https://repo.maven.apache.org/maven2/org/jenkins-ci/tools/maven-hpi-plugin/3.12/maven-hpi-plugin-3.12.jar
[WARNING] Failed to build parent project for org.jenkins-ci.plugins:telegram-notifications:hpi:1.4.1-SNAPSHOT

Invalid parameter "chatId"

I tried using chaId to send multiple groups. The syntax is as below.
telegramSend(message: 'Test', chatId: xxxx)
I have received the error: Invalid parameter "chatId".
who can help me?

Option to disable or escape markdown in message

If you pass message with unpaired markdown formatting symbols like this "Build branch origin\test_branch" it fails to send message, because of non-closed "_".
I tried to do escaping for this kind of symbols, but it is real pain to do this and pass through build steps, maybe proper solution will be provide an option to send as plain text or HTML to Telegram?

out of range of int

Jenkins and plugins versions report

com.fasterxml.jackson.core.JsonParseException: Numeric value (5xxxxxxxxx) out of range of int
at [Source: (String)"{"ok":true,"result":[{"update_id":1xxxxxxxx,
"message":{"message_id":1,"from":{"id":5xxxxxxxxx,"is_bot":false,"first_name":"---","language_code":"en"},"chat":{"id":5xxxxxxxxx,"first_name":"---","type":"private"},"date":1660388790,"text":"/start","entities":[{"offset":0,"length":6,"type":"bot_command"}]}},{"update_id":131742974,
"my_chat_member":{"chat":{"id":-6xxxxxxxx,"title":"---","type":"group","all_members_are_administrators":true},"from":{"id":5xxxxxxxxx,"is_bot":false"[truncated 6844 chars]; line: 2, column: 50]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1804)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:693)
at com.fasterxml.jackson.core.base.ParserBase.convertNumberToInt(ParserBase.java:886)
at com.fasterxml.jackson.core.base.ParserBase._parseIntValue(ParserBase.java:801)
at com.fasterxml.jackson.core.base.ParserBase.getIntValue(ParserBase.java:645)
at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$IntegerDeserializer.deserialize(NumberDeserializers.java:472)
at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$IntegerDeserializer.deserialize(NumberDeserializers.java:452)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
Caused: com.fasterxml.jackson.databind.JsonMappingException: Numeric value (5xxxxxxxxx) out of range of int
at [Source: (String)"{"ok":true,"result":[{"update_id":1xxxxxxxx,
"message":{"message_id":1,"from":{"id":5xxxxxxxxx,"is_bot":false,"first_name":"---","language_code":"en"},"chat":{"id":5xxxxxxxxx,"first_name":"---","type":"private"},"date":1660388790,"text":"/start","entities":[{"offset":0,"length":6,"type":"bot_command"}]}},{"update_id":131742974,
"my_chat_member":{"chat":{"id":-6xxxxxxxx,"title":"---","type":"group","all_members_are_administrators":true},"from":{"id":5xxxxxxxxx,"is_bot":false"[truncated 6844 chars]; line: 2, column: 40] (through reference chain: org.telegram.telegrambots.meta.api.objects.ApiResponse["result"]->java.util.ArrayList[0]->org.telegram.telegrambots.meta.api.objects.Update["message"]->org.telegram.telegrambots.meta.api.objects.Message["from"]->org.telegram.telegrambots.meta.api.objects.User["id"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:353)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1711)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:290)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3023)
at org.telegram.telegrambots.meta.api.methods.updates.GetUpdates.deserializeResponse(GetUpdates.java:113)
Caused: org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException: Unable to deserialize response
at org.telegram.telegrambots.meta.api.methods.updates.GetUpdates.deserializeResponse(GetUpdates.java:121)
at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$ReaderThread.getUpdatesFromServer(DefaultBotSession.java:257)
at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$ReaderThread.run(DefaultBotSession.java:186)

What Operating System are you using (both controller, and any agents involved in the problem)?

Windows 10

Reproduction steps

when new bot is added

Expected Results

added bod

Actual Results

not work

Anything else?

No response

Message do not sended. [400] Bad Request: can't parse entities

I get error Jenkins log all.
Message do not sended.
I'm not use mardown, simple Letter and number, like Version = ${version_parametr}, in log job i see Version = 123, but in log jenkins i see next error:
org.telegram.telegrambots.exceptions.TelegramApiRequestException: Error sending message: [400] Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 133 at org.telegram.telegrambots.api.methods.send.SendMessage.deserializeResponse(SendMessage.java:170) at org.telegram.telegrambots.api.methods.send.SendMessage.deserializeResponse(SendMessage.java:24) at jenkinsci.plugins.telegrambot.telegram.TelegramBot.sendApiMethodWithProxy(TelegramBot.java:222) at jenkinsci.plugins.telegrambot.telegram.TelegramBot.execute(TelegramBot.java:153) at jenkinsci.plugins.telegrambot.telegram.TelegramBot.sendMessage(TelegramBot.java:80) at jenkinsci.plugins.telegrambot.telegram.TelegramBot.lambda$sendMessage$0(TelegramBot.java:102) at java.lang.Iterable.forEach(Iterable.java:75) at jenkinsci.plugins.telegrambot.telegram.TelegramBot.sendMessage(TelegramBot.java:102) at jenkinsci.plugins.telegrambot.TelegramBotBuilder.perform(TelegramBotBuilder.java:63) at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744) at hudson.model.Build$BuildExecution.build(Build.java:206) at hudson.model.Build$BuildExecution.doRun(Build.java:163) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504) at hudson.model.Run.execute(Run.java:1810) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429)

Exception during send message.

Version report

Jenkins and plugins versions report:

Jenkins: 2.277.1
OS: Linux - 5.4.0-66-generic
---
generic-webhook-trigger:1.72
branch-api:2.6.2
config-file-provider:3.7.0
blueocean-github-pipeline:1.24.4
conditional-buildstep:1.4.1
antisamy-markup-formatter:2.1
pipeline-model-definition:1.8.4
jdk-tool:1.5
resource-disposer:0.14
github:1.33.1
docker-java-api:3.1.5.2
matrix-project:1.18
github-pr-coverage-status:2.1.1
email-ext:2.81
pipeline-github:2.7
docker-plugin:1.2.2
blueocean-jira:1.24.4
pipeline-stage-tags-metadata:1.8.4
cloudbees-folder:6.15
lockable-resources:2.10
ant:1.11
sse-gateway:1.24
docker-workflow:1.25
blueocean-commons:1.24.4
javadoc:1.6
okhttp-api:3.14.9
blueocean-pipeline-editor:1.24.4
workflow-step-api:2.23
pollscm:1.3.1
blueocean-git-pipeline:1.24.4
telegram-notifications:1.4.0
multibranch-scan-webhook-trigger:1.0.5
jquery-detached:1.2.1
pipeline-multibranch-defaults:2.1
jenkins-design-language:1.24.4
git-client:3.6.0
blueocean-web:1.24.4
pipeline-stage-view:2.19
plugin-util-api:1.7.1
blueocean-bitbucket-pipeline:1.24.4
workflow-scm-step:2.11
gradle:1.36
mailer:1.32.1
pipeline-rest-api:2.19
blueocean-i18n:1.24.4
git:4.6.0
workflow-cps-global-lib:2.17
icon-shim:2.0.3
authentication-tokens:1.4
plain-credentials:1.7
checks-api:1.5.0
blueocean-display-url:2.4.1
structs:1.22
blueocean-rest:1.24.4
maven-plugin:3.8
apache-httpcomponents-client-4-api:4.5.13-1.0
durable-task:1.35
blueocean-jwt:1.24.4
ssh-slaves:1.31.5
command-launcher:1.5
blueocean:1.24.4
github-branch-source:2.9.6
parameterized-trigger:2.39
blueocean-dashboard:1.24.4
echarts-api:4.9.0-3
handy-uri-templates-2-api:2.1.8-1.0
pam-auth:1.6
blueocean-autofavorite:1.2.4
workflow-job:2.40
jjwt-api:0.11.2-9.c8b45b8bb173
jquery:1.12.4-1
favorite:2.3.2
ace-editor:1.1
jquery3-api:3.5.1-2
workflow-cps:2.89
handlebars:1.1.1
blueocean-pipeline-api-impl:1.24.4
snakeyaml-api:1.27.0
jira:3.2
blueocean-pipeline-scm-api:1.24.4
htmlpublisher:1.25
blueocean-rest-impl:1.24.4
bootstrap4-api:4.6.0-1
blueocean-config:1.24.4
scm-api:2.6.4
matrix-auth:2.6.6
pipeline-githubnotify-step:1.0.5
pipeline-build-step:2.13
cloudbees-bitbucket-branch-source:2.9.7
ssh-credentials:1.18.1
momentjs:1.1.1
workflow-aggregator:2.6
jsch:0.1.55.2
mercurial:2.12
credentials-binding:1.24
pipeline-input-step:2.12
display-url-api:2.3.4
github-api:1.122
pipeline-github-lib:1.0
workflow-api:2.41
build-with-parameters:1.5
github-pullrequest:0.2.8
ansible:1.1
variant:1.4
pipeline-model-extensions:1.8.4
pubsub-light:1.13
bouncycastle-api:2.18
pipeline-model-api:1.8.4
blueocean-events:1.24.4
timestamper:1.11.8
git-server:1.9
ws-cleanup:0.38
pipeline-graph-analysis:1.10
workflow-basic-steps:2.23
popper-api:1.16.1-1
blueocean-core-js:1.24.4
blueocean-personalization:1.24.4
workflow-multibranch:2.22
ldap:1.26
docker-commons:1.17
token-macro:2.13
workflow-support:3.7
script-security:1.76
font-awesome-api:5.15.2-1
workflow-durable-task-step:2.37
run-condition:1.5
jackson2-api:2.12.1
credentials:2.3.15
junit:1.48
build-timeout:1.20
trilead-api:1.0.13
pipeline-stage-step:2.5
pipeline-milestone-step:1.3.2
Parameterized-Remote-Trigger:3.1.5.1
Result: [Plugin:generic-webhook-trigger, Plugin:branch-api, Plugin:config-file-provider, Plugin:blueocean-github-pipeline, Plugin:conditional-buildstep, Plugin:antisamy-markup-formatter, Plugin:pipeline-model-definition, Plugin:jdk-tool, Plugin:resource-disposer, Plugin:github, Plugin:docker-java-api, Plugin:matrix-project, Plugin:github-pr-coverage-status, Plugin:email-ext, Plugin:pipeline-github, Plugin:docker-plugin, Plugin:blueocean-jira, Plugin:pipeline-stage-tags-metadata, Plugin:cloudbees-folder, Plugin:lockable-resources, Plugin:ant, Plugin:sse-gateway, Plugin:docker-workflow, Plugin:blueocean-commons, Plugin:javadoc, Plugin:okhttp-api, Plugin:blueocean-pipeline-editor, Plugin:workflow-step-api, Plugin:pollscm, Plugin:blueocean-git-pipeline, Plugin:telegram-notifications, Plugin:multibranch-scan-webhook-trigger, Plugin:jquery-detached, Plugin:pipeline-multibranch-defaults, Plugin:jenkins-design-language, Plugin:git-client, Plugin:blueocean-web, Plugin:pipeline-stage-view, Plugin:plugin-util-api, Plugin:blueocean-bitbucket-pipeline, Plugin:workflow-scm-step, Plugin:gradle, Plugin:mailer, Plugin:pipeline-rest-api, Plugin:blueocean-i18n, Plugin:git, Plugin:workflow-cps-global-lib, Plugin:icon-shim, Plugin:authentication-tokens, Plugin:plain-credentials, Plugin:checks-api, Plugin:blueocean-display-url, Plugin:structs, Plugin:blueocean-rest, Plugin:maven-plugin, Plugin:apache-httpcomponents-client-4-api, Plugin:durable-task, Plugin:blueocean-jwt, Plugin:ssh-slaves, Plugin:command-launcher, Plugin:blueocean, Plugin:github-branch-source, Plugin:parameterized-trigger, Plugin:blueocean-dashboard, Plugin:echarts-api, Plugin:handy-uri-templates-2-api, Plugin:pam-auth, Plugin:blueocean-autofavorite, Plugin:workflow-job, Plugin:jjwt-api, Plugin:jquery, Plugin:favorite, Plugin:ace-editor, Plugin:jquery3-api, Plugin:workflow-cps, Plugin:handlebars, Plugin:blueocean-pipeline-api-impl, Plugin:snakeyaml-api, Plugin:jira, Plugin:blueocean-pipeline-scm-api, Plugin:htmlpublisher, Plugin:blueocean-rest-impl, Plugin:bootstrap4-api, Plugin:blueocean-config, Plugin:scm-api, Plugin:matrix-auth, Plugin:pipeline-githubnotify-step, Plugin:pipeline-build-step, Plugin:cloudbees-bitbucket-branch-source, Plugin:ssh-credentials, Plugin:momentjs, Plugin:workflow-aggregator, Plugin:jsch, Plugin:mercurial, Plugin:credentials-binding, Plugin:pipeline-input-step, Plugin:display-url-api, Plugin:github-api, Plugin:pipeline-github-lib, Plugin:workflow-api, Plugin:build-with-parameters, Plugin:github-pullrequest, Plugin:ansible, Plugin:variant, Plugin:pipeline-model-extensions, Plugin:pubsub-light, Plugin:bouncycastle-api, Plugin:pipeline-model-api, Plugin:blueocean-events, Plugin:timestamper, Plugin:git-server, Plugin:ws-cleanup, Plugin:pipeline-graph-analysis, Plugin:workflow-basic-steps, Plugin:popper-api, Plugin:blueocean-core-js, Plugin:blueocean-personalization, Plugin:workflow-multibranch, Plugin:ldap, Plugin:docker-commons, Plugin:token-macro, Plugin:workflow-support, Plugin:script-security, Plugin:font-awesome-api, Plugin:workflow-durable-task-step, Plugin:run-condition, Plugin:jackson2-api, Plugin:credentials, Plugin:junit, Plugin:build-timeout, Plugin:trilead-api, Plugin:pipeline-stage-step, Plugin:pipeline-milestone-step, Plugin:Parameterized-Remote-Trigger]
  • What Operating System are you using (both controller, and any agents involved in the problem)?
Docker jenkinceci\jenkinsci:2.277.1-alpine

Reproduction steps

Jenkinsfile:

telegramSend chatId: "$CHAT_ID", message: "Error during build: ${BUILD_URL}"

Results

Expected result:

Message sends

Actual result:

java.lang.IllegalStateException
	at org.objectweb.asm.tree.analysis.BasicInterpreter.<init>(BasicInterpreter.java:66)
	at org.parboiled.transform.RuleMethodInterpreter.<init>(RuleMethodInterpreter.java:42)
	at org.parboiled.transform.InstructionGraphCreator.process(InstructionGraphCreator.java:41)
	at org.parboiled.transform.ParserTransformer.runMethodTransformers(ParserTransformer.java:62)
	at org.parboiled.transform.ParserTransformer.extendParserClass(ParserTransformer.java:45)
	at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:39)
	at org.parboiled.Parboiled.createParser(Parboiled.java:54)
Caused: java.lang.RuntimeException: Error creating extended parser class: null
	at org.parboiled.Parboiled.createParser(Parboiled.java:58)
	at org.jenkinsci.plugins.tokenmacro.Parser.process(Parser.java:80)
	at org.jenkinsci.plugins.tokenmacro.Parser.process(Parser.java:74)
	at org.jenkinsci.plugins.tokenmacro.TokenMacro.expand(TokenMacro.java:199)
	at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:237)
	at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:207)
	at jenkinsci.plugins.telegrambot.telegram.TelegramBot.expandMessage(TelegramBot.java:92)
	at jenkinsci.plugins.telegrambot.telegram.TelegramBot.sendMessage(TelegramBot.java:104)
	at jenkinsci.plugins.telegrambot.TelegramBotMessager.perform(TelegramBotMessager.java:71)
	at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:99)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:69)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Add channels support

As a Jenkins user, I want to send messages from different projects to different telegram chats e.g.
build and deploy have to send messages to dev-chat. But test job have to send messages to qa-chat

Jenkins 2.303.3: telegramSend failed with java.net.URISyntaxException: Illegal character in path

Version report

Jenkins and plugins versions report:

Jenkins: 2.303.3
OS: Windows Server 2012 R2 - 6.3
---
ace-editor:1.1
active-directory:2.25
ant:1.12
antisamy-markup-formatter:2.4
apache-httpcomponents-client-4-api:4.5.13-1.0
authentication-tokens:1.4
binary-deployer:0.1
blueocean:1.25.1
blueocean-autofavorite:1.2.4
blueocean-bitbucket-pipeline:1.25.1
blueocean-commons:1.25.1
blueocean-config:1.25.1
blueocean-core-js:1.25.1
blueocean-dashboard:1.25.1
blueocean-display-url:2.4.1
blueocean-events:1.25.1
blueocean-git-pipeline:1.25.1
blueocean-github-pipeline:1.25.1
blueocean-i18n:1.25.1
blueocean-jira:1.25.1
blueocean-jwt:1.25.1
blueocean-personalization:1.25.1
blueocean-pipeline-api-impl:1.25.1
blueocean-pipeline-editor:1.25.1
blueocean-pipeline-scm-api:1.25.1
blueocean-rest:1.25.1
blueocean-rest-impl:1.25.1
blueocean-web:1.25.1
bootstrap4-api:4.6.0-3
bootstrap5-api:5.1.3-1
bouncycastle-api:2.25
branch-api:2.7.0
build-environment:1.7
build-name-setter:2.2.0
build-notifications:1.6.1-SNAPSHOT (private-4e4371d6-leon)
build-pipeline-plugin:1.5.8
caffeine-api:2.9.2-29.v717aac953ff3
checks-api:1.7.2
cloudbees-bitbucket-branch-source:2.9.11
cloudbees-folder:6.16
cmakebuilder:4.1.0
command-launcher:1.6
compress-artifacts:1.10
conditional-buildstep:1.4.1
config-file-provider:3.8.1
configuration-as-code:1.54
content-replace:1.6.0
copyartifact:1.46.2
cppcheck:1.25
credentials:2.6.1
credentials-binding:1.27
cvs:2.19
depgraph-view:1.0.5
disk-usage:0.28
display-url-api:2.3.5
docker-commons:1.17
docker-java-api:3.1.5.2
docker-plugin:1.2.3
docker-workflow:1.26
downstream-buildview:1.9
dtkit-api:3.0.0
durable-task:1.39
dynamic-axis:1.0.3
echarts-api:5.2.2-1
email-ext:2.84
envinject:2.4.0
envinject-api:1.8
extensible-choice-parameter:1.8.0
external-monitor-job:1.7
favorite:2.3.3
file-operations:1.11
font-awesome-api:5.15.4-1
fstrigger:0.41
git:4.10.0
git-client:3.10.0
git-parameter:0.9.13
git-server:1.10
github:1.34.1
github-api:1.133
github-branch-source:2.11.3
gitlab-api:1.0.6
gitlab-branch-source:1.5.9
gitlab-plugin:1.5.22
google-oauth-plugin:1.0.6
google-play-android-publisher:4.2
gradle:1.37.1
groovy:2.4
h2-api:1.4.199
handlebars:3.0.8
handy-uri-templates-2-api:2.1.8-1.0
htmlpublisher:1.27
jackson2-api:2.13.0-230.v59243c64b0a5
javadoc:1.6
jaxb:2.3.0.1
jdk-tool:1.5
jenkins-design-language:1.25.1
jira:3.6
jjwt-api:0.11.2-9.c8b45b8bb173
jobConfigHistory:2.28.1
jquery:1.12.4-1
jquery-detached:1.2.1
jquery3-api:3.6.0-2
jsch:0.1.55.2
junit:1.53
last-changes:2.7.10
ldap:2.7
locale:1.4
lockable-resources:2.12
mailer:1.34
mapdb-api:1.0.9.0
mask-passwords:3.0
matrix-auth:2.6.8
matrix-groovy-execution-strategy:1.0.7
matrix-project:1.19
maven-plugin:3.15.1
mercurial:2.15
momentjs:1.1.1
msbuild:1.30
next-build-number:1.7
nodejs:1.4.1
oauth-credentials:0.5
okhttp-api:4.9.2-20211102
pam-auth:1.6.1
parameterized-trigger:2.41
pipeline-build-step:2.15
pipeline-github-lib:1.0
pipeline-graph-analysis:1.11
pipeline-input-step:2.12
pipeline-maven:3.10.0
pipeline-milestone-step:1.3.2
pipeline-model-api:1.9.2
pipeline-model-definition:1.9.2
pipeline-model-extensions:1.9.2
pipeline-npm:0.9.2
pipeline-rest-api:2.19
pipeline-stage-step:2.5
pipeline-stage-tags-metadata:1.9.2
pipeline-stage-view:2.19
pipeline-utility-steps:2.10.0
plain-credentials:1.7
plugin-util-api:2.5.1
popper-api:1.16.1-2
popper2-api:2.10.2-1
powershell:1.7
publish-over:0.22
publish-over-ssh:1.22
pubsub-light:1.16
pyenv-pipeline:2.1.2
rebuild:1.32
ruby-runtime:0.12
run-condition:1.5
scm-api:2.6.5
scp:1.8
script-security:1.78
shared-workspace:1.0.2
snakeyaml-api:1.29.1
sse-gateway:1.24
ssh:2.6.1
ssh-agent:1.23
ssh-credentials:1.19
ssh-slaves:1.33.0
ssh-steps:2.0.0
sshd:3.1.0
structs:1.23
subversion:2.15.1
svnpublisher:0.1
telegram-notifications:1.4.0
thinBackup:1.10
throttle-concurrents:2.4
timestamper:1.13
token-macro:267.vcdaea6462991
translation:1.16
trilead-api:1.0.13
urltrigger:0.49
variables-replace-plugin:1.0.0
variant:1.4
windows-slaves:1.8
workflow-aggregator:2.6
workflow-api:2.47
workflow-basic-steps:2.24
workflow-cps:2633.v6baeedc13805
workflow-cps-global-lib:545.v7b28cce323cf
workflow-durable-task-step:2.40
workflow-job:2.42
workflow-multibranch:2.26
workflow-scm-step:2.13
workflow-step-api:2.24
workflow-support:3.8
xcode-plugin:2.0.15
xunit:3.0.4
yaml-axis:0.3.0
  • What Operating System are you using (both controller, and any agents involved in the problem)?
OS: Windows Server 2012 R2 - 6.3

Reproduction steps

  • Update to Jenkins 2.303.3
  • Create simple pipeline:
pipeline {
    agent any
    stages {
        stage('Send') {
            steps {
                telegramSend(message: 'Send without chatId')
            }
        }
    }
}
  • Run the just created pipeline which finished successfully, but message is not appeared in the chat
  • Open %JENKINS_HOME%/jenkins.err.log and search for
2021-11-08 13:48:17.107+0000 [id=4574921]	SEVERE	j.p.t.telegram.TelegramBot#sendMessage: Error while sending the message
java.net.URISyntaxException: Illegal character in path at index 28: https://api.telegram.org/bot{AQAAABAA....==}/sendmessage
	at java.net.URI$Parser.fail(URI.java:2848)
	at java.net.URI$Parser.checkChars(URI.java:3021)
	at java.net.URI$Parser.parseHierarchical(URI.java:3105)
	at java.net.URI$Parser.parse(URI.java:3053)
	at java.net.URI.<init>(URI.java:588)
	at java.net.URI.create(URI.java:850)
Caused: java.lang.IllegalArgumentException: Illegal character in path at index 28: https://api.telegram.org/bot{AQAAABAA....==}/sendmessage
	at java.net.URI.create(URI.java:852)
	at org.apache.http.client.methods.HttpPost.<init>(HttpPost.java:73)
	at jenkinsci.plugins.telegrambot.telegram.TelegramBot.configuredHttpPost(TelegramBot.java:174)
	at jenkinsci.plugins.telegrambot.telegram.TelegramBot.sendMethodRequest(TelegramBot.java:250)
	at jenkinsci.plugins.telegrambot.telegram.TelegramBot.sendApiMethodWithProxy(TelegramBot.java:238)
	at jenkinsci.plugins.telegrambot.telegram.TelegramBot.execute(TelegramBot.java:170)
	at jenkinsci.plugins.telegrambot.telegram.TelegramBot.sendMessage(TelegramBot.java:81)
	at jenkinsci.plugins.telegrambot.telegram.TelegramBot.lambda$sendMessage$0(TelegramBot.java:109)
	at java.lang.Iterable.forEach(Iterable.java:75)
	at jenkinsci.plugins.telegrambot.telegram.TelegramBot.sendMessage(TelegramBot.java:109)
	at jenkinsci.plugins.telegrambot.TelegramBotMessager.perform(TelegramBotMessager.java:71)
	at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:100)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:70)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
  • Revert to Jenkins 2.303.2
  • Run the just created pipeline and message send to the chat

Results

Expected result: message must be sent to the chat as on Jenkins 2.303.2

Actual result: exception URISyntaxException on Jenkins 2.303.3

Unable to send Environment Variables on Windows Environment

Windows variables will be encapsulated as such %ENV_VARIABLE%. So far I've not been able to send telegram messages with variables in my Windows environment.

I've tried:

  • %ENV_VARIABLE%
  • %ENV_VARIABLE%
  • $ENV_VARIABLE
  • $ENV_VARIABLE

Please advise if this has been considered. Thanks!

Error removing old webhook

Error in last 1.3.0 version
What is this error about?

org.telegram.telegrambots.exceptions.TelegramApiRequestException: Error removing old webhook: [404] Not Found
	at org.telegram.telegrambots.bots.TelegramLongPollingBot.clearWebhook(TelegramLongPollingBot.java:49)
	at org.telegram.telegrambots.TelegramBotsApi.registerBot(TelegramBotsApi.java:120)
	at jenkinsci.plugins.telegrambot.telegram.TelegramBotRunner.createBotSession(TelegramBotRunner.java:66)
	at jenkinsci.plugins.telegrambot.telegram.TelegramBotRunner.lambda$new$0(TelegramBotRunner.java:61)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

environment variables

Good morning,

Not really an issue. Is there a list of environment variables we can use in the message ? And also how to use them ?

I tried $BRANCH_NAME $JOB_NAME $JOB_URL and ${BRANCH_NAME} ${JOB_NAME} ${JOB_URL} and it does not seem to work.

add Fixed status

I wanted to have in addition to Success, Unstable, Failed, Aborted also the status Fixed.

jenkins.plugins.telegram.endpoint.TelegramBot$1 onGetUpdatesFailure

Getting (literally) millions of error messages in Jenkins log file located in /var/log/jenkins/jenkins.log

As the following:

WARNING: exception occured while processing updates from telegram
org.apache.commons.httpclient.HttpException: call to telegram returned unexpected http status code 404
        at jenkins.plugins.telegram.TelegramService.getRawUpdate(TelegramService.java:83)
        at jenkins.plugins.telegram.bot.polling.TelegramLongPoller.getNewUpdates(TelegramLongPoller.java:76)
        at jenkins.plugins.telegram.bot.polling.TelegramLongPoller.run(TelegramLongPoller.java:53)

Jenkins crashed a couple of times in the last month, and I suspect it's because of the log file getting oversized (reaching ~8GB) because of this error message

Error sending message: [400] Bad Request: message is too long

Good day.

I got an error below when the plugin tried to send a message:

Error sending message
org.telegram.telegrambots.exceptions.TelegramApiRequestException: Error sending message: [400] Bad Request: message is too long
        at org.telegram.telegrambots.api.methods.send.SendMessage.deserializeResponse(SendMessage.java:170)
        at org.telegram.telegrambots.api.methods.send.SendMessage.deserializeResponse(SendMessage.java:24)
        at org.telegram.telegrambots.bots.DefaultAbsSender.sendApiMethod(DefaultAbsSender.java:689)
        at org.telegram.telegrambots.bots.AbsSender.execute(AbsSender.java:53)
        at com.itransition.iam.telegram.bots.JiraBot$sendMsg$1.run(JiraBot.kt:332)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

Plugin version:

0.9.14

Setting plugin

Thanks so much for such a plugin!

There are several questions, please tell me
How can I configure the body of the forwarded message?
How can I set up a build start notification?

Everything you need to build, the beginning or end of the assembly, and much more

Perhaps it is somehow configured?

Update README

Update the README.md file to include useful features that were implemented

No sent system messages or messages from the item Jenkins

I added to the field Telegram Bot name, Telegram Bot token, but I don't get system messages or messages from the item Jenkins.
Environment:
Ubuntu 16.04,
Jenkins ver. 2.138.1
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

In the Jenkins log I see the massange below:

`Oct 05, 2018 11:35:46 AM INFO jenkinsci.plugins.telegrambot.telegram.TelegramBot initializeProxy

Proxy successfully initialized

Oct 05, 2018 11:35:46 AM INFO jenkinsci.plugins.telegrambot.telegram.TelegramBotRunner lambda$new$1

Bot was created

Oct 05, 2018 11:35:46 AM SEVERE jenkinsci.plugins.telegrambot.telegram.TelegramBotRunner createBotSession

Telegram API error
javax.net.ssl.SSLHandshakeException: Received fatal alert: access_denied
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2038)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1135)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
at org.telegram.telegrambots.bots.TelegramLongPollingBot.clearWebhook(TelegramLongPollingBot.java:43)
Caused: org.telegram.telegrambots.exceptions.TelegramApiRequestException: Error executing setWebook method
at org.telegram.telegrambots.bots.TelegramLongPollingBot.clearWebhook(TelegramLongPollingBot.java:55)
at org.telegram.telegrambots.TelegramBotsApi.registerBot(TelegramBotsApi.java:120)
at jenkinsci.plugins.telegrambot.telegram.TelegramBotRunner.createBotSession(TelegramBotRunner.java:84)
at jenkinsci.plugins.telegrambot.telegram.TelegramBotRunner.lambda$new$1(TelegramBotRunner.java:75)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)`

Telegram Bot Not Send message

Jenkins and plugins versions report

telegramSend(message: "Hello World", chatId: 977645935)

What Operating System are you using (both controller, and any agents involved in the problem)?

Ubuntu 20

Reproduction steps

Write name and Token in Global Setting

Expected Results

Recieve Message

Actual Results

Message Not Recieved

Anything else?

No response

Proxy (socks5) support request

Hello,
We have blocked almost all of the internet in our company ? have only few messengers proxies, so I need a way to configure this plugin so it may use proxy.

Message with underscore character is not sent

Hi there!

I have multibranch pipeline and I get git commiter email this way:

GIT_COMMITER_EMAIL = sh(script: 
     "git --no-pager show -s --format='%ce' $GIT_COMMIT", 
     returnStdout: true).
trim()

Then I try to send message to telegram like this:

telegramSend "Build project failed! \n" +
     "Author: ${GIT_COMMITER_EMAIL} \n" +
     "Branch name: ${BRANCH_NAME}"

I see in Jenkins console log:

Post stage
[Pipeline] step
Build project failed! 
Author: [email protected]
Branch name: notifications

But I have nothing in telegram. As soon as I comment the line contains ${GIT_COMMITER_EMAIL}, message is sent correctly.

I tried to hardcode my email instead of using variable - the result is the same: message is not sent without any errors.

Thanks in advance
Best regards!

The bot does not work. At all.

Hello fellow developers

I have installed the bot, and followed the guide. I configured the bot name and token. Here's what I see in the jenkins log:

2021-02-08 14:09:06.889+0000 [id=44] INFO j.p.t.telegram.TelegramBotRunner#lambda$new$0: There is no reason for bot recreating
2021-02-08 14:13:29.607+0000 [id=44] INFO j.p.t.telegram.TelegramBot#initializeProxy: Proxy successfully initialized
2021-02-08 14:13:29.613+0000 [id=44] INFO j.p.t.telegram.TelegramBotRunner#lambda$new$0: Bot was created

I assume this means the bot was started.

I put this to my pipeline:

post {
    always {            
        telegramSend '${currentBuild.projectName} ${currentBuild.displayName} ${currentBuild.result}'   
    }
}

The build is successful. But I get no notifications in telegram chat. Also /start and /sub and /help do not return any answer. What could be wrong?

How to send notification in bot?

So I have such problem. I write my message without any command into field, and nothing happens inside console on postbuild steps. So, could you provide an example of filling this text box? Or method for checking of working bot.

Missing working example

Hi,
I would like to use this plugin, but there is lack of example how this is suppose to work. I have spend few hours combine how this stuff can be configured together and Im still facing an issues that:

  1. What's Telegram Bot name it's a username of bot with @ or without @? Or maybe it's display name but with suffix bot or without?
  2. /sub command at telegram boot chat doesn't return anyhing
  3. manual approval doesn't display any user after /sub
  4. messages are not publish by bot

There is so manny missing information that I can not make any progress of how to use it.

Please @nikitabelonogov describe it a bit better.

Underscore character

Hi there!
My ${BRANCH_NAME} value has the underscore character, but it is missing while sending the message.
My script is:

telegramSend 
     "Build project failed! \n" + 
     "Branch name: ${BRANCH_NAME}"

I see in Jenkins console log:

Post stage
[Pipeline] step
Build project failed! 
Branch name: telegram_notification

But message in telegram looks like this:

Build project failed! 
Branch name: telegramnotification

('notification' in 'telegramnotification' is in italic)

I didn't see this error until today, underscore characters in branch names were resolved correctly.

Thanks in advance
Best regards!

Add params to Snippet Generator

Hi! I got message This step has not yet defined any visual configuration. on Pipeline Syntax -> Snippet Generator.
It will be very convenient to be able to fill in the parameters through this section.

image

This step has not yet defined any visual configuration.

How to send notifications to groups or channels?

Hi, I've followed the instructions on README and I can get the bot to send the messages from Jenkins jobs to me (which means I have to /sub directly to the bot). I have yet to found a way to send notifications to groups and channels. I added the bot the channels, but what are the next steps?

It seems that we can though, like in #8 and #17. Did I miss something?

Thanks!

Error in jenkins global log - TelegramBot.java:134

Message was sent, but i see error in global log jenkins. in job console log - no errors....
version 1.30

Something bad happened while message processing java.lang.NullPointerException at jenkinsci.plugins.telegrambot.telegram.TelegramBot.processNonCommandUpdate(TelegramBot.java:134) at org.telegram.telegrambots.bots.commandbot.TelegramLongPollingCommandBot.onUpdateReceived(TelegramLongPollingCommandBot.java:76) at java.util.ArrayList.forEach(ArrayList.java:1257) at org.telegram.telegrambots.generics.LongPollingBot.onUpdatesReceived(LongPollingBot.java:27) at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$HandlerThread.run(DefaultBotSession.java:311)

Escaping environmental variables

Hi there!
I just started using this wonderful plugin but it took me a while to figure out why my messages where not getting through: my BUILD_URL has a _ inside and I was using that variable inside the message.

Is there any way to escape this variables? Also, is there a way to include the job status in the message (failed, success)?

Thanks in advance
Best regards!

Add "Token Macro Plugin" support

I want to publish my git changes ${GITCHANGELOG} to telegram from Git Changelog Plugin.
But this plugin does not consume a tokens

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.