Changing email body programmatically is possible now.
- You can go to Manage Jenkins > Configure System and set Default Content as
${FILE,path="email-body.html"}
under Extended E-mail Notification area.
Now, you just have to generate email-body.html file programmatically directly under your workspace root.
Sample code:
@After
public void writeLog() throws IOException {
File file = new File("email-body.html");
StringBuilder htmlBuilder = new StringBuilder();
htmlBuilder.append("<html>");
htmlBuilder.append("<head><title>Hello World</title></head>");
htmlBuilder.append("<body><p>Look at my body!</p></body>");
htmlBuilder.append("</html>");
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file));
bufferedWriter.write(htmlBuilder.toString());
bufferedWriter.close();
}
Also, make sure that default content type is set to HTML.