jenkinsci / slack-plugin

A Jenkins plugin for posting notifications to a Slack channel
https://plugins.jenkins.io/slack/
MIT License
670 stars 413 forks source link

not sending two successive notifications in slack (peer not authenticated) #858

Open vishal-elimu opened 1 year ago

vishal-elimu commented 1 year ago

Jenkins and plugins versions report

Environment ```text Paste the output here ```

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

OS : Ubuntu 18:04 Jenkins-agent : Same host (Ubuntu 18:04) Jenkins version: Jenkins 2.346.2

Reproduction steps

  1. Enabled "Notify Success" in post build action in jenkins job. (Jenkins version 2.346.2, Slack Notification Plugin version Version631.v40deea_40323b)
  2. Ran the same jenkins job twice. I get notification only for one build of job
  3. Get notification on alternate build/run of job. Example: gets slack notification for job's build number 2, 4, 6, 8 so jenkins/slack notification plugin skips every alternate build notification.

image

Expected Results

  1. Upon every successfully build / run of job I should get notification
  2. When job fails I should get "Job Failed" notification/message
  3. When job fails but next build of job runs successfully then I should get notification with "back to normal" message

Actual Results

  1. If job fails (consider build no : 4) and then next build (build no: 5) runs successfully then I should get notified with "back to normal " notification but it does not. I get notification for "failed build" (build no : 4) but not for next build (build no : 5)
  2. Sometimes when job fails I don't get notification (consider build no: 6) but I get notification (back to normal) when next build of job runs successfully (build no: 7)
  3. When job runs successfully twice (consider build no 8 and 9) I only get notification for build no : 8
  4. My observation is that jenkins/plugin not sending two successive notifications in slack and it skips one notification image image

Jenkins logs

WARNING j.p.slack.StandardSlackService#postToSlack: Error posting to Slack javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated at java.base/sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:526) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.verifyHostname(SSLConnectionSocketFactory.java:504) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:437) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:384) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376) at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) 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 jenkins.plugins.slack.StandardSlackService.postToSlack(StandardSlackService.java:214) at jenkins.plugins.slack.StandardSlackService.publish(StandardSlackService.java:340) at jenkins.plugins.slack.StandardSlackService.publish(StandardSlackService.java:379) at jenkins.plugins.slack.StandardSlackService.publish(StandardSlackService.java:351) at jenkins.plugins.slack.workflow.SlackSendStep$SlackSendStepExecution.run(SlackSendStep.java:359) at jenkins.plugins.slack.workflow.SlackSendStep$SlackSendStepExecution.run(SlackSendStep.java:258) at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834)

Anything else?

No response

thomasvincent commented 1 year ago

I ran into the same thing, and I believe it was fixed in the latest version of the plugin. My work around the problem was by using the slackNotify step

pipeline {
  agent any

  stages {
    stage('Build') {
      steps {
        echo 'Building...'
      }
    }

    stage('Notify Slack') {
      steps {
        slackNotify channel: '#general', message: 'Build successful!'
      }
    }
  }
}
vishal-elimu commented 1 year ago

@thomasvincent I tried it and ran the pipeline but it failed with below error message java.lang.NoSuchMethodError: No such DSL method 'slackNotify' found among steps

timja commented 1 year ago

you mustn't have the slack plugin installed then or it's failed to start

vishal-elimu commented 1 year ago

@timja slack plugin is installed and using version 631.v40deea_40323b I am able to use slackSend commands in pipeline steps but issue still persist, not able to get 2 successive slack notifications (I do receive every alternate slack notification).

timja commented 1 year ago

Ah right my mistake.

vishal-elimu commented 1 year ago

@timja , @thomasvincent I just updated jenkins logs above,

I am seeing a lot of WARNING j.p.slack.StandardSlackService#postToSlack: Error posting to Slack javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated at messages in jenkins container.

Do you guys have an idea about these warning messages ?

timja commented 1 year ago

possibly outdated system libraries or a MITM proxy on your side?

Basically a network issue specific to you.

see also https://github.com/jenkinsci/slack-plugin/issues/837#issuecomment-1206810299

vishal-elimu commented 1 year ago

Thanks Tim, I will take a look