1

I'm trying to display HTML page content into the body of the Jenkins email, i added the following code to the default content section in Editable Email plugin:

${FILE,path="/target/surefire-reports/html/index.html"}

also i tried to add the following code to Pre-send Script in the Email plugin:

def reportPath = build.getWorkspace().child("HealthTestResults.html")
msg.setContent(reportPath.readToString(), "text/html");

both of the two way didn't work and i'm still receiving empty mails.

Roni
  • 604
  • 2
  • 6
  • 12

2 Answers2

0

What about have a try with DSL, if you don't bother have one more Jenkins job

You can:

  1. Add a new build step "Process Job DSLs" (You will need Job DSL Plugin)
  2. Add this Groovy script to "Use the provided DSL script" field

Groovy script

job(jobname_to_your_email_job) {
  publishers {
    extendedEmail {
      recipientList(your_email_list)
      defaultSubject(your_subject)
      defaultContent(your_default_content)
      contentType('text/html')
      triggers {
        always {
          subject(your_subject)
          //read your html file and put it in the content field
          content(readFileFromWorkspace(path_to_your_html_file))
          sendTo {
            recipientList()
          }
        }
      }
    }
  }
}
//This will put your email job to the build queue so your email job will run automatically
queue("Email Report")

And of course, you can customize this part according to the Docs

Chong
  • 335
  • 2
  • 9
  • could you go check the job created by this groovy script to see the content field of "editable email" in the post-build step? Is it empty or not? – Chong Apr 10 '17 at 08:53
  • I used the above mentioned Groovy script.I checked in the job created by groovy script. The content field contains html script... But receiving empty mails only – user2439278 Jun 07 '17 at 09:52
0

Tried ${FILE,path="target/surefire-reports/html/index.html"}? ie without the /

David van Laatum
  • 634
  • 4
  • 13