user3021914
user3021914

Reputation: 143

Display HTML page inside mail body with Email-ext plugin

I'm facing a little problem using Email-ext plugin on Jenkins.

I added the following line to inject my surefire html result to the email sent by the plugin :

${FILE,path="server/target/site/surefire-report.html"} 

and I put contenant type as HTML (text/html)

I'm using Jenkins 1.651.1 and Email-ext plugin 2.42

I receive an e-mail in the end of my build with the following contenent

 ${FILE,path="server/target/site/surefire-report.html"} 

It's like the plugin did not understand any thing.

Do you have an idea ?

any update on that ? my project structure is like this :

workspace

    master
    commun 
    server/target/surefire-report/surefire-report.html

Upvotes: 0

Views: 3157

Answers (3)

Sergey Pleshakov
Sergey Pleshakov

Reputation: 8948

If you use a custom path this answer is for you

I had a complication trying to achieve this result because my path was dynamically changing and I had to use a variable inside a FILE variable. So when I tried any of the following

body: '${FILE,path=${report}}'
body: "${FILE,path=${report}}"
body: '''${FILE,path=${report}}'''

and many more, it didn't work. On the other hand I couldn't read the file with groovy because of Jenkins restrictions

My workaround was to read the html directly with groovy sh command like so

html_body = sh(script: "cat ${report}", returnStdout: true).trim()

and then just send the email

emailext replyTo: '$DEFAULT_REPLYTO',
  subject: "subject",
  to: EMAIL,
  mimeType: 'text/html',
  body: html_body

where ${report} was a path to html file like /var/jenkins/workspace_318/report.html

Upvotes: 1

AnonUser
AnonUser

Reputation: 1

I was also having the prob where the mail had the command with error coould not find file. Like mentioned above, the html file should be present exactly under the jenkins workspace folder. if not then give the relative path, even an extra "/" in front seems to throw error. ex: My file is in C:\CICDJenkins\ReadyAPIReport\summary.html My jenkins workpace (im using custom workspace) is C:\CICDJenkins

what worked for me is: ${FILE, path="ReadyAPI_report/overview-summary.html"}

Upvotes: 0

prudviraj
prudviraj

Reputation: 3744

Please note that file path is relative to the workspace , if file resides in the root of your workspace , filename alone in the path will work , if it resides in a different location try somthing like this below :

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

Upvotes: 0

Related Questions