从Jenkins运行时,通过电子邮件发送emailable-report.html的功能不起作用,但在本地运行良好。
我有一个仅在测试用例执行后发送带有emailable-report.html的电子邮件的功能。在我的本地计算机上工作正常。但是,从Jenkins运行时,构建成功,但没有发送电子邮件。我已经设置了主机名,并且smtp端口与Jenkins服务器匹配。
String reportLocation ="..\\target\\surefire-reports\\emailable-report.html";
EmailAttachment attachment = new EmailAttachment();
attachment.setPath(reportLocation);
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setDescription("Test Report " + timeStamp + ".html");
// Create the email message
MultiPartEmail email = new MultiPartEmail();
email.setHostName("x.x.x.x"); //SERVER .
email.setSmtpPort(25);
email.addTo("user@gmail.com");
email.setFrom("//another email address", "Me");
email.setSubject("Selenium WebDriver Test Report, run from Jenkin (SERVER) " + dateTest);
email.setMsg("-- This is a Test Report email. Please refer to the attachment for more details!");
email.attach(attachment);
// send the email
email.send();
System.out.println("Test Report Mail Sent Successfully");