Reputation: 73
Here I mention the email stage def subject = "Job ${buildStatus} - ${env.JOB_NAME} - Build
${env.BUILD_NUMBER}"
echo "env variable running"
echo "${subject}"
def summary = "${subject}"
echo "${summary}"
def details = """ Your Job's build has been ${buildStatus}. Click the URL to view the build log. \n\n ${env.BUILD_URL} \n\n Sent from JustOps.io"""
echo "${details}"
mail to: "[email protected]",
subject: "${summary}",
body: "${details}"
I am getting following error Error when executing success post condition:
javax.mail.MessagingException: IOException while sending message;
nested exception is:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;
boundary="----=_Part_755_422232966.1533023412891"
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1141)
at javax.mail.Transport.send0(Transport.java:195)
at javax.mail.Transport.send(Transport.java:124)
at org.jenkinsci.plugins.workflow.steps.MailStep$MailStepExecution.run(MailStep.java:142)
at org.jenkinsci.plugins.workflow.steps.MailStep$MailStepExecution.run(MailStep.java:128)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1$1.call(SynchronousNonBlockingStepExecution.java:50)
at hudson.security.ACL.impersonate(ACL.java:290)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1.run(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)
Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;
boundary="----=_Part_755_422232966.1533023412891"
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:896)
at javax.activation.DataHandler.writeTo(DataHandler.java:317)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1476)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1772)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1099)
... 12 more
Upvotes: 0
Views: 795
Reputation: 939
in a scripted pipeline you would do something like this
import javax.activation.MailcapCommandMap;
import javax.activation.CommandMap;
@NonCPS
def setupMail(){
MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
mc.addMailcap("message/rfc822;; x-java-content- handler=com.sun.mail.handlers.message_rfc822");
}
node {
setupMail()
mail( from: '[email protected]',
replyTo: '[email protected]',
to: [email protected],
subject: "Hi there MIME",
body: "It Works!")
}
Bug is tracked here https://issues.jenkins-ci.org/browse/JENKINS-53305
Upvotes: 1
Reputation: 4516
This is due to underlying JavaMail not configured for mime types. An html handler is provided in JavaMail 1.1.3 but the mailcap file is not configured for this. Try adding the below line -
text/html;; x-java-content-handler=com.sun.mail.handlers.text_html
Upvotes: 1