0
votes

In Jenkins, there's a plugin for sending notifications once the job runs for various triggers. This plugin depends upon setting mail server in Jenkins global configuration.

Editable Email Notification Plugin - Fails the whole build if the mail server is not reachable (port 25) or for some reason if the edit email notification post action fails (for various triggers we set in the job's config).

Now, if I have a build/deploy job which completed successfully (in doing main stuff) but failed during the sending email part (due to some mail server issue) then why it's marking the whole job as failed.

The email trigger action should not mark the build as FAILED (if email trigger part failed due to a mail server issue) and Jenkins should either queue the email up (for sending the email at a later point once mail server is back/up/online OR the post action should just not have any impact to the job's status). If email trigger fails, just echo - Email sending action failed as mail server had an issue due to this / that (detail message).

How can I get rid of this situation. I have a long running job and I don't want to re-run it (if I know that the mail server is back online) and even if I re-run the job, I'm not 100% sure that the mail server will be up/running or not.

Just trying to see if there's an option we can set in Edit Email Notification to not mark the build job as FAILED if email notification step fails (i.e. enhancement to this plugin) OR some other way I can get rid of this situation.

17:15:55 ERROR: Could not send email as a part of the post-build publishers.
17:15:55 javax.mail.MessagingException: Could not connect to SMTP host: my-mailhost.company.com, port: 25;
17:15:55   nested exception is:
17:15:55    java.net.ConnectException: Connection refused
17:15:55    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934)
17:15:55    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
17:15:55    at javax.mail.Service.connect(Service.java:295)
17:15:55    at javax.mail.Service.connect(Service.java:176)
17:15:55    at javax.mail.Service.connect(Service.java:125)
17:15:55    at javax.mail.Transport.send0(Transport.java:194)
17:15:55    at javax.mail.Transport.send(Transport.java:124)
17:15:55    at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:306)
17:15:55    at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:281)
17:15:55    at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:233)
17:15:55    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
17:15:55    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:772)
17:15:55    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:736)
17:15:55    at hudson.model.Build$BuildExecution.cleanUp(Build.java:192)
17:15:55    at hudson.model.Run.execute(Run.java:1778)
17:15:55    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
17:15:55    at hudson.model.ResourceController.execute(ResourceController.java:88)
17:15:55    at hudson.model.Executor.run(Executor.java:234)
17:15:55 Caused by: java.net.ConnectException: Connection refused
17:15:55    at java.net.PlainSocketImpl.socketConnect(Native Method)
17:15:55    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
17:15:55    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
17:15:55    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
17:15:55    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
17:15:55    at java.net.Socket.connect(Socket.java:519)
17:15:55    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:286)
17:15:55    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:231)
17:15:55    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1900)
17:15:55    ... 17 more
17:15:55 Finished: FAILURE
1

1 Answers

2
votes

No options are found to get rid of your situlation in the email plugin, though i rechecked the plugin's config.

Maybe Parameterized Trigger Plugin could save your time in some other way as i know.

  1. To Create two jobs: project-A(main) and project-B
  2. To Configure Trigger parameterized build on other projects in main project-A so as to trigger project-B to run.
  3. Project-B just send emails if main project-A runs stablely. So the result of the main project-A won't be effected by the offline mail server.
  4. The parameters needed in the email could be transfered easily through the plugin.

I hope this could help you!