Display HTML page inside mail body with Email-ext plugin in Jenkins

大憨熊 提交于 2019-12-17 08:49:30

问题


I am new to Jenkins and i want to know how it is possible to display the html report (not the html code) generated after a successful build inside a mail body (not an attachment).

I want to know the exact steps i should follow and what should be the content of my possible jelly template.


回答1:


Look deeper into the plugin documentations. No need for groovy here.

Just make sure Content Type is set to HTML and add the following to the body:

${FILE,path="my.html"}

This will place the my.html content in your email body (location of file is relative to job's workspace. I use it and it works well.

I hope this helps.

EDIT: Note that you must have the Jenkins version 1.532.1 (or higher) to support this feature with the email-ext plugin.




回答2:


It worked for me with Jenkins 1.558

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



回答3:


You just need to assign the link to the environment variable and then you can use that variable to print in the email using ${ENV, var=ENV_VARIABLE}.




回答4:


It should be something like this:

Navigation: [Configure -> Editable Email Notification]

Default Content: ${FILE,path="path/result.html"}




回答5:


You can use Editable Email Notification post build action to send html content as part of mail body.

Copy html content in Default Content and select Content Type as HTML (text/html), as in below image:




回答6:


Besides reading the file with body: ${FILE,path="index.html"}, you need to set the proper content type, either globally or explicitly for one execution, with mimeType: 'text/html.

emailext subject: '$DEFAULT_SUBJECT',
                    body: '${FILE,path="index.html"}',
                    recipientProviders: [
                        [$class: 'CulpritsRecipientProvider'],
                        [$class: 'DevelopersRecipientProvider'],
                        [$class: 'RequesterRecipientProvider']
                    ], 
                    replyTo: '$DEFAULT_REPLYTO',
                    to: '$DEFAULT_RECIPIENTS',
                    mimeType: 'text/html'


来源:https://stackoverflow.com/questions/22066936/display-html-page-inside-mail-body-with-email-ext-plugin-in-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!