jenkinsci / telegram-notifications-plugin

This plugin allows you to send messages from Jenkins jobs to Telegram chat.
https://plugins.jenkins.io/telegram-notifications/
MIT License
72 stars 62 forks source link

TelegramToken problems #60

Open Rufics opened 3 years ago

Rufics commented 3 years ago

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="telegram-notifications@1.4.0">
  <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)
zerthimon commented 3 years ago

I second this

marfx000 commented 3 years ago

https://github.com/jenkinsci/telegram-notifications-plugin/pull/61 this PR should fix the problem. just in case I've attached already fixed plugin to that comment (unzip it before using), you can manually install it using this instruction https://www.jenkins.io/doc/book/managing/plugins/

telegram-notifications.hpi.zip

zerthimon commented 3 years ago

This PR has been merged. When can we expect a release, to update our installations ?