I am using Jenkins and email-ext to send build notifications. Build produces small custom report stored as simple HTML in out<\/code> directory.
Right now I can easy attach this report to the email, but what I want is to have this report rendered to the email body itself. I know that I can write my own jelly template, but this requires access to the build server(to install jelly script), I want to avoid this too. So my questions are:
<\/li>
<\/li><\/ol>"
It looks like most easy way is to use 'Pre-send Script' of the Email-ext
Script looks like this:
def reportPath = build.getWorkspace().child("HealthTestResults.html")
msg.setContent(reportPath.readToString(), "text/html");
It renders content of the HealthTestResults.html located in the root of the workspace just as body of the message.
Easy way to include the html file to email content is to add below line in the default content = ${FILE, path="yourfilename.html"}
this works for me in jenkins email ext plugin
I try it using
def reportPath = build.getWorkspace().child("HealthTestResults.html")
msg.setContent(reportPath.readToString(), "text/html");
But the email sent out is like this:
Frame Alert This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
Do you know the reason? Mike Chaliy
If you use groovy template, then you can do something like this
stage("Notifications") {
steps {
script {
env.ForEmailPlugin = env.WORKSPACE
emailext mimeType: "text/html",
body: '''${SCRIPT, template="notification.template"}''',
subject: env.JENKINS_PROJECT + " " + currentBuild.currentResult + " : " + env.JOB_NAME + "/" + env.GIT_COMMIT,
recipientProviders: [requestor(), developers()],
from: env.JENKINS_EMAIL,
attachLog: true
}
}
}
and slice of /var/lib/jenkins/email-templates/notification.template
<!-- ARGOCD SYNC OUTPUT -->
<h3>ArgoCD<h3/>
<hr size="1" />
<tt>
${new File("/tmp/sync.txt").text.replaceAll('\n','<br>').replaceAll(' ', ' ')}
</tt>
I am trying below script in pipeline after some stages. It throws below error. What could be the reason?
post {
always {
emailext body: '', presendScript: '''def reportPath = build.getWorkspace().child("test-output/emailable-report.html")
msg.setContent(reportPath.readToString(), "text/html");''', subject: '', to: ‘someone@somewhere.com'
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.