Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-16181

Jenkins does not try to resend a failed e-mail

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Sending an e-mail from a job could fail for several reasons, for example:

      • connection refused in case smtp is temporarily overloaded
      • smtp server temporarily down

      If this happens, jenkins does not try to resend the e-mail.
      This can be a problem if you rely on e-mail notifications to identify critical systems or builds that fail.

      Can this be fixed?

        Attachments

          Activity

          Hide
          slide_o_mix Alex Earl added a comment -

          I would consider doing it for connection refused or failed connections, but I would only retry a couple of times so it didn't take too long.

          Show
          slide_o_mix Alex Earl added a comment - I would consider doing it for connection refused or failed connections, but I would only retry a couple of times so it didn't take too long.
          Hide
          kalm Kate Calm added a comment -

          Maybe you can consider a queueing mechanism (asynchronously), but a few retries would already be great!

          Show
          kalm Kate Calm added a comment - Maybe you can consider a queueing mechanism (asynchronously), but a few retries would already be great!
          Hide
          slide_o_mix Alex Earl added a comment -

          I don't think a queuing mechanism would be a good idea. I'll look into retries for specific issues (socket exceptions, etc).

          Show
          slide_o_mix Alex Earl added a comment - I don't think a queuing mechanism would be a good idea. I'll look into retries for specific issues (socket exceptions, etc).
          Hide
          kutzi kutzi added a comment -

          IMHO Jenkins is not responsible for reliable e-mail delivery (if you want such thing, you should make your e-mail infrastructure reliable). But some - not too many! - retries probably won't hurt!
          But remember that this may needlessly delay the completion of jobs if the e-mail server continues to be unavailable.

          Show
          kutzi kutzi added a comment - IMHO Jenkins is not responsible for reliable e-mail delivery (if you want such thing, you should make your e-mail infrastructure reliable). But some - not too many! - retries probably won't hurt! But remember that this may needlessly delay the completion of jobs if the e-mail server continues to be unavailable.
          Hide
          slide_o_mix Alex Earl added a comment -

          I agree, this is why I will restrict the number of retries to maybe even just one.

          Show
          slide_o_mix Alex Earl added a comment - I agree, this is why I will restrict the number of retries to maybe even just one.
          Hide
          kalm Kate Calm added a comment -

          One retry would already be nice!
          Any idea when this can be implemented?

          Show
          kalm Kate Calm added a comment - One retry would already be nice! Any idea when this can be implemented?
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Alex Earl
          Path:
          src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java
          src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptorTest.java
          http://jenkins-ci.org/commit/email-ext-plugin/3af25cc2606cf0147376870d32de5930521e6a6f
          Log:
          Fix JENKINS-16181

          • Added a retry on SocketException occuring
          • Added commented out main descriptor test, this will be used later

          Compare: https://github.com/jenkinsci/email-ext-plugin/compare/52dae3a93c5a...3af25cc2606c


          You received this message because you are subscribed to the Google Groups "Jenkins Commits" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-commits+unsubscribe@googlegroups.com.
          For more options, visit https://groups.google.com/groups/opt_out.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptorTest.java http://jenkins-ci.org/commit/email-ext-plugin/3af25cc2606cf0147376870d32de5930521e6a6f Log: Fix JENKINS-16181 Added a retry on SocketException occuring Added commented out main descriptor test, this will be used later Compare: https://github.com/jenkinsci/email-ext-plugin/compare/52dae3a93c5a...3af25cc2606c – You received this message because you are subscribed to the Google Groups "Jenkins Commits" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-commits+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out .
          Hide
          slide_o_mix Alex Earl added a comment -

          Added a retry on SocketException occuring.

          Show
          slide_o_mix Alex Earl added a comment - Added a retry on SocketException occuring.
          Hide
          marktrinh Mark Trinh added a comment -

          I'm using 2.27.1 and i'm not seeing any retry messages.
          Email was triggered for: Success
          Sending email for trigger: Success
          Sending email to: xxx@xx.com
          ERROR: Could not send email as a part of the post-build publishers.
          javax.mail.MessagingException: Could not connect to SMTP host: smtp.xx.com, port: 25;
          nested exception is:
          java.net.ConnectException: Connection refused
          at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
          at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
          at javax.mail.Service.connect(Service.java:275)
          at javax.mail.Service.connect(Service.java:156)
          at javax.mail.Service.connect(Service.java:105)
          at javax.mail.Transport.send0(Transport.java:168)
          at javax.mail.Transport.send(Transport.java:98)
          at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:317)
          at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:296)
          at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:256)
          at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
          at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:703)
          at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:678)
          at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:656)
          at hudson.model.Build$RunnerImpl.cleanUp(Build.java:171)
          at hudson.model.Run.run(Run.java:1452)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
          at hudson.model.ResourceController.execute(ResourceController.java:88)
          at hudson.model.Executor.run(Executor.java:238)
          Caused by: java.net.ConnectException: Connection refused
          at java.net.PlainSocketImpl.socketConnect(Native Method)
          at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:337)
          at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:198)
          at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
          at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
          at java.net.Socket.connect(Socket.java:579)
          at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:230)
          at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
          at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
          ... 18 more

          Show
          marktrinh Mark Trinh added a comment - I'm using 2.27.1 and i'm not seeing any retry messages. Email was triggered for: Success Sending email for trigger: Success Sending email to: xxx@xx.com ERROR: Could not send email as a part of the post-build publishers. javax.mail.MessagingException: Could not connect to SMTP host: smtp.xx.com, port: 25; nested exception is: java.net.ConnectException: Connection refused at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370) at javax.mail.Service.connect(Service.java:275) at javax.mail.Service.connect(Service.java:156) at javax.mail.Service.connect(Service.java:105) at javax.mail.Transport.send0(Transport.java:168) at javax.mail.Transport.send(Transport.java:98) at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:317) at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:296) at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:256) at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36) at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:703) at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:678) at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:656) at hudson.model.Build$RunnerImpl.cleanUp(Build.java:171) at hudson.model.Run.run(Run.java:1452) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:238) Caused by: java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:337) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:198) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) at java.net.Socket.connect(Socket.java:579) at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:230) at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189) at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250) ... 18 more
          Hide
          slide_o_mix Alex Earl added a comment -

          Retry will currently only occur on SocketExceptions, would need to add something for ConnectException

          Show
          slide_o_mix Alex Earl added a comment - Retry will currently only occur on SocketExceptions, would need to add something for ConnectException
          Hide
          marktrinh Mark Trinh added a comment -

          Adding ConnectException would be very helpful. Do you think it is possible?

          Show
          marktrinh Mark Trinh added a comment - Adding ConnectException would be very helpful. Do you think it is possible?
          Hide
          slide_o_mix Alex Earl added a comment -

          Will add for the next release

          Show
          slide_o_mix Alex Earl added a comment - Will add for the next release
          Hide
          arost Alexander Ost added a comment -

          Apparently, retry handling for the "connetion refused" case does not yet work properly.

          I do observe the following stack trace whenever the SMTP server is unreachable:

          javax.mail.MessagingException: Could not connect to SMTP host: mail.example.net, port: 25;
          nested exception is:
          java.net.ConnectException: Connection refused
          at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934)
          at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
          at javax.mail.Service.connect(Service.java:295)
          at javax.mail.Service.connect(Service.java:176)
          at javax.mail.Service.connect(Service.java:125)
          at javax.mail.Transport.send0(Transport.java:194)
          at javax.mail.Transport.send(Transport.java:124)
          at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:305)

          ...but I can never see a "Socket error sending email, retrying once more in 10 seconds" message.

          I suspect that the root cause is that Transport.send() will not throw a SendFailedException in this case, but rather a MessagingException. However, the plugin code only catches SendFailedException.

          (Tested with version email-ext-2.37.2.2, but exception type handling is identical on master.)

          Could you please check?

          Show
          arost Alexander Ost added a comment - Apparently, retry handling for the "connetion refused" case does not yet work properly. I do observe the following stack trace whenever the SMTP server is unreachable: javax.mail.MessagingException: Could not connect to SMTP host: mail.example.net, port: 25; nested exception is: java.net.ConnectException: Connection refused at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638) at javax.mail.Service.connect(Service.java:295) at javax.mail.Service.connect(Service.java:176) at javax.mail.Service.connect(Service.java:125) at javax.mail.Transport.send0(Transport.java:194) at javax.mail.Transport.send(Transport.java:124) at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:305) ...but I can never see a "Socket error sending email, retrying once more in 10 seconds" message. I suspect that the root cause is that Transport.send() will not throw a SendFailedException in this case, but rather a MessagingException . However, the plugin code only catches SendFailedException. (Tested with version email-ext-2.37.2.2, but exception type handling is identical on master.) Could you please check?
          Hide
          johnwynne John Wynne added a comment -

          Alexander, I am seeing the exact same issue as you and it started at around the same time you posted your comment. I am only seeing it intermittantly though, is it the same for you or are you seeing it with every email? Perhaps this is a new issue?
          I looked for an option to specify the number of retries for an email failure but couldn't find one. Does a feature like this exist?

          Show
          johnwynne John Wynne added a comment - Alexander, I am seeing the exact same issue as you and it started at around the same time you posted your comment. I am only seeing it intermittantly though, is it the same for you or are you seeing it with every email? Perhaps this is a new issue? I looked for an option to specify the number of retries for an email failure but couldn't find one. Does a feature like this exist?
          Hide
          slide_o_mix Alex Earl added a comment -

          There is no option to specify the number of retries.

          Show
          slide_o_mix Alex Earl added a comment - There is no option to specify the number of retries.
          Hide
          christiangalsterer Christian Galsterer added a comment -

          Added handling when a MessagingException is caused by ConnectException. Identical retry handling as for SendFailedException.
          PR available at https://github.com/jenkinsci/email-ext-plugin/pull/96

          Show
          christiangalsterer Christian Galsterer added a comment - Added handling when a MessagingException is caused by ConnectException. Identical retry handling as for SendFailedException. PR available at https://github.com/jenkinsci/email-ext-plugin/pull/96
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Christian Galsterer
          Path:
          src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java
          http://jenkins-ci.org/commit/email-ext-plugin/531a9232658a3bb725be1f0551a1bb01ec30c588
          Log:
          JENKINS-16181 Jenkins does not try to resend a failed e-mail

          • Added handling where MessagingConnection is caused by a ConnectException. One retry with a delay of 10 sec is made.
          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Christian Galsterer Path: src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java http://jenkins-ci.org/commit/email-ext-plugin/531a9232658a3bb725be1f0551a1bb01ec30c588 Log: JENKINS-16181 Jenkins does not try to resend a failed e-mail Added handling where MessagingConnection is caused by a ConnectException. One retry with a delay of 10 sec is made.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Alex Earl
          Path:
          src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java
          http://jenkins-ci.org/commit/email-ext-plugin/99ff8aed9777edfd24420ed3ba91a6d9f322968a
          Log:
          Merge pull request #96 from christiangalsterer/JENKINS-16181

          JENKINS-16181 Jenkins does not try to resend a failed e-mail

          Compare: https://github.com/jenkinsci/email-ext-plugin/compare/5a0f29b55751...99ff8aed9777

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java http://jenkins-ci.org/commit/email-ext-plugin/99ff8aed9777edfd24420ed3ba91a6d9f322968a Log: Merge pull request #96 from christiangalsterer/ JENKINS-16181 JENKINS-16181 Jenkins does not try to resend a failed e-mail Compare: https://github.com/jenkinsci/email-ext-plugin/compare/5a0f29b55751...99ff8aed9777
          Hide
          slide_o_mix Alex Earl added a comment -

          Fixed in 2.39

          Show
          slide_o_mix Alex Earl added a comment - Fixed in 2.39

            People

            Assignee:
            slide_o_mix Alex Earl
            Reporter:
            kalm Kate Calm
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: