Including TestNG Reports within the Jenkins Email Notifications.

Hi All,

This post mainly is for those who have Selenium scripts running as part of their Jenkins Jobs & want to include these results within the main body of the Jenkins Emailable Notification.


1.For the Post Build Actions > Select Editable Email Notifications

2.If this option is not there as part of post build actions, the email-ext-plugin is needed to be installed on Jenkins. Go to

3.Select Content Type as HTML(text/plain)

4.In the Default Content section : remove $DEFAULT_CONTENT.Place the following code to inject your html report into the default content :-

${FILE,path=”relative path to html file”}

Eg: ${FILE,path=”MyWorkspace/MyProj/test-output/emailable-report.html”}

This will place the emailable-report.html content in your email body.

5.You can further choose the various trigger points to include the test report i.e on success, test failures (any) , unstable etc.

Hope this is of use to someone struggling out there and landed up here!



63 responses to “Including TestNG Reports within the Jenkins Email Notifications.

  1. How to add dynamic report name in Eg: ${FILE,path=”MyWorkspace/MyProj/test-output/dynamicname.html”}

    In my case report is generated with a different name after every run.


      • Path is : C:/Users/Automation/SVN/ADSS/java_adss_v2/target/chrome/emailable-report.html



      • What is your Jenkins Workspace path??…

        Basically you should configure your Jenkins Job in such a way that the Automation Workspace must be within your Jenkins Workspace.

        Eg -E:\JenkinsSlave\workspace\Your_Automation_Workspace

        So your automation reports will be seen as :-


        Then you can attach the report using the relative path of the Jenkins workspace for the corresponding job.



      • the code i m using in Default_content :


        Content_Type: HTML(text/html) other options are:

        Default, PlainText(text/plain), both html amd plain text.


  2. hi VJ

    1-> Jenkins workspace path is: C:\Program Files\Jenkins\workspace

    my project path is: C:\Users\Automation\SVN\ADSS\java_adss_v2

    now i copied my project in “jenkins/workspace”.

    now the path is: C:\Program Files\Jenkins\workspace\ADSS_J\java_adss_v2_J

    this path i m giving in Jenkins Default_Content as: ${FILE,path=”C:\Program Files\Jenkins\workspace\ADSS_J\java_adss_v2_J\emailable-report.html”}…

    even i tried with {${FILE,path=”\ADSS_J\java_adss_v2_J\emailable-report.html”} in Default_Content.

    but still its not working.

    2->In Jenkins workspace i have folders with build names, i tried to attach a file from one of the folder, still it didnt work.

    eg. ${FILE,path=”C:\Program Files\Jenkins\workspace\123demo\Always-15-1086240151.html”}. here 123demo is the build name.

    3->what i get is ” ${FILE,path=”C:\Program Files\Jenkins\workspace\123demo\Always-15-1086240151.html”} ” in mail body, no attachment.

    Please buddy tell me what to do. i have a deadline very soon.



    • This is what you need to give as part of your mail body :-


      i.e relative path from the Jenkins Job(in your case from 123demo).You need to exclude the job name as well

      Also select content type as HTML (text/html).

      Let me know if it works…


  3. can u plz help out to send mail…

    Content Type HTML

    Default Subject

    Default Content ${FILE,path=D:\Jenkins\Jenkinsproject\JenkinsPracties\emailable-report.html”}


    • Hi Suresh,
      First things first… How are you triggering the selenium scripts? ….

      Also the path you give must be relative to your jenkins workspace. Here you have given the absolute path…


  4. Hi

    I am stuck when trying to send html report through email notification .
    Jenkins workspace path is C:\jenkins\workspace\FinanceworksAutomation\development\software\pfw\main\Automation\FW_Automation_New\target\surefire-reports

    I gave it as ${FILE,path=”target/surefire-reports/emailable-report.html”}
    what is receive in email is
    ERROR: File ‘target/surefire-reports/emailable-report.html’ does not exist


    • Path of the file must be relative to the project… so if your project name is “FinanceworksAutomation”, then try this out :-



  5. Hey

    Its been a full day now, and I havent got any success in getting Testng reports in email once the Jenkins Job run. I doubt if at all its possible because I have tried all possible ways

    I configured Jenkins Job and here are the details of Editable Email Notification in Jenkins Job :

    Default Content –
    ${FILE,path=”a/tests/target/surefire-reports/emailable-report.html”} – This is the path to my testng html file. The Jenkins Jobs workspace

    starts with ws and complete path to the file from workspace is ws/a/tests/target/surefire-reports/emailable-report.html
    Let me know if this path is not correct ? I though have tried all possible options here.

    When I give the file path to Attachments field as – tech.core/tech.core.api.tests/target/surefire-reports/index.html

    I do get an attachment with the email But that doesn’t contain any image. Also when I click the attachment, the report is highly distorted and no styling/css is applied on to it.

    Let me know if it is possible to get Testng reports via email so that I can send these to stakeholders. I thought this to be a very very common requirement and did not
    expected it to take so much time to resolve/configure.

    I have high expectations to get an answer here !! Any help highly appreciated as its an urgent requirement at my end



  6. Thanks a lot! This helped a bunch. Had to struggle with Jenkins and company email settings before I could use this nut thanks, it really helped.
    Also, if you can edit the post to specify that you don’t need to add the path to the project and workspace in the path, that’d be great.


  7. Hi,
    I have configured the extended email configurations under 1. Project configuration, 2. Global configuration & email template.Also, have configured email to trigger for all scenarios, configured the jenkins workspace same as project workspace as per your suggestion in previous posts.Have tried all the possible options of FILE paths as discussed in your blog. When i build the project, i receive mail notification only when build fails with build failure logs and for successful builds, i only get a notification with jenkins url without any attachments !!
    i have run out of options and badly need you help.


    • Hi Srikanth,
      I have a feeling you are going wrong with your configuration of the email notification. Firstly you need the ‘Email Extension Plugin’ & ‘Email Extension Template Plugin’

      In editable email notification specific to each job do the following steps :-

      1.Click on Advanced Settings.
      2.Click on Add Trigger
      3.Over there add a trigger, like Failure,Success etc
      4.Again click on Advanced
      5.Select Content type as html
      6.Add your content for each trigger with HTML tags along with it
      7.Also select ‘Do not attach Build Log’

      You should be able to get it working. Let me know how it goes.



  8. Hi,
    I have run out of options trying to configure extended email with attachments.
    1. Configured the email trigger for all the scenarios.
    2. Workspace for Jenkins &project are same.
    3. Tried all possible paths for FILE,path
    4. Configured extended email configurations for all the three Project configurations, Global configurations & email template.

    I receive emails with logs only on build failures without attachments & email notification with only a Jenkins URL on build success.

    I have urgent deliverables and need your help very very badly !!


  9. This post is a great help in setup – thank you! I can receive emails based on my trigger, and include the build.log. But I can not get my emailable-report.html to attach. Every email comes through with a line of text like:

    ${FILE,path=”CRM Service Tests\target\surefire-reports\emailable-report.html”}

    I am running on Windows 10 as a Jenkins slave to a linux Jenkins server. On the windows slave, my full path is:

    C:\Jenkins\workspace\CRM Service Tests\target\surefire-reports

    I have tried different combinations of relative and absolute paths to the file, using forward and backslash, leading of each one. I have even tried a static file at C:/Jenkins/workspace/test.txt , C:\Jenkins\workspace\test.txt, and test.txt.

    I still cant get the report or attachment. Any help would be greatly appreciated!!


    • Hey Jason,
      Try this out :-
      >Click on Triggers in Editable Email Notifications section
      >You have a field named “Attachments”.
      >Give the absolute/relative path of your file in that editbox.

      I wish I could help you better by trying this out myself, but I’ve switched jobs so been away from implementing Jenkins stuff for a while. Though I’ll be back on it in a few weeks time 🙂

      Let me know if this helps.


  10. Hi,
    It is working fine for me.
    But my query is sometimes the html is not created
    At that time, I am getting error message like file doesn’t exist
    Is there any option to not throw an error in email body if the file is not available?


    • Hey Nivedithaa,
      I’m not sure how we can do that… Do let me know if you can find out a solution for it. I’m unsure if we can include some sort of logic in the editable email notification plugin to handle such cases. But definitely worth a try.


  11. Or you need to just put below command in your attachments section in Editable Email Notification:



  12. Hey I am using:

    I have set the content type as HTML(text/html)

    But i am seeing the text “${FILE,path=”reports/emailable-report.html”}” in the email body.

    However, when i use the path reports/emailable-report.html then i can see the report as an attachment.



  13. I configured the project as u mentioned but once the test is completed I’m not able to send the mail I’m getting the following lines.

    Email was triggered for: Always
    Sending email for trigger: Always
    Sending email to:
    Connection error sending email, retrying once more in 10 seconds…
    Connection error sending email, retrying once more in 10 seconds…
    Failed after second try sending email

    Please help me to solve this issue.


    • Hey Durga,
      I think you’ve not configured the SMTP server for jenkins.
      To configure your SMTP server Go to Manage Jenkins >> Configure System.

      Then in Email Notification section give in the SMPT server details of your organisation. Let me know if it works.


  14. hi , i have a requirement to embed an jpeg image file in the email . i am able to add the image as attachment , but i would want to embed. I am using the editable email notification section. content type i have used html and also tried html and plain text. In the default content i have the following

    The image is also present in a server path. It is also hosted on a webserver.I have also copied that image in the jenkins job workspace also.

    But when i give the above code , only the first one works . This server location cannot be accessed outside office network. So i want the other two to work. Please help me find out why this does not seem to work.


  15. I use cucumber extent and try to send it, but the mail doesn’t include html formatting and all the report without design,
    How can i send a report with HTML page formatting?


    • Hey Eitan,
      You can custom make html reports if needed. Just read up on html basics, on how to make a table with different rows and columns. Use a language of your choice to create the html report.


  16. Hi,
    I am able to get html in my email body but after receiving the contents it is showing body as plain lines and all the html stylings are gone. Without styling it is looking very bad. Is there a way to resolve this?
    If i want to write a script and parse a html for html body what do i have do?


    • Hi Kanheiya.. I am also having same issue. If your issue got resolved, please let me know ! Because i have received email body without Proper UI. Please help me!


  17. Hey hi Vj,
    I am able to get the emailable-report.html as attachment but when i set the pre-send-script: def reportPath = build.getWorkspace().child(“Portal/portalTests/test-output/surefire/**/emailable-report.html”)
    msg.setContent(reportPath.readToString(), “text/html”);

    i get an error in jenkins saying:
    Caused by: /Users/admin/jenkins/workspace/ScmPlanningAndBuyingUITests/Portal/portalTests/test-output/surefire/**/emailable-report.html (No such file or directory)

    the actual path to the report is: Portal/portalTests/test-output/surefire/${timestamp}/emailable-report.html and i am using the wildcard since the groovy script cannot is not able to recognise ${timestamp}.

    also i tried setting ${FILE,path=”Portal/portalTests/test-output/surefire/${timestamp}/emailable-report.html”} in the default content, but it prints the above statement in the email

    any idea where am i going wrong?


  18. hi VJ,
    please can you assist me
    i have followed ur steps and successfully generated reports and recieved those reports to my outlook but the issue that i am facing is, the reports that i am receiving in outlook does not have CSS formatting (i.e graphs, colours are missing in the mail)
    kindly can you advise me on the same. i am completely new to Jenkins and selenium



  19. How to check file(reports/emailable-report.html) exist or not before running

    In my case, some time report will not be generated . In this case i want to display some message.


  20. ${FILE,path=”E:/Jenkins/SERA_AutomationSuit/workspace/SpecFramework.SL.TestProject/bin/Debug

    Job name: SERA_AutomationSuit
    Project: SpecFramework.SL.TestProject
    inside Debug folder all my .html files are generated everytime jenkins builds run

    Now how to pass it dynamically after debug such that after every jenkins runs it picks up the file automatically


    what to pass in ?

    My HTML file format looks like: SpecFramework.SL.TestProject_Default_2017-10-06T181730.html

    where date time stamp changes every time

    Please help?


  21. Hi vj,

    For adding test results in the email body, I followed your steps.
    Since I’ve some other contents as well (apart from the relative path) in the default content, it’s just printing the path in the email body.

    I want the email to display the content (such as: This is auto-generated email to publish test results. Please find the build report below) with the index.html. Is it possible?


  22. Hey please help ASAP

    My File path in Jenkins is job/testFreeStyle/ws/extentReportFile.html

    I got this following error when I try to attach the file by this line

    06:39:48 ERROR: Error accessing files to attach: Expecting Ant GLOB pattern, but saw ‘/var/lib/jenkins/workspace/testFreeStyle/extentReportFile.html’. See for syntax
    06:39:48 An attempt to send an e-mail to empty list of recipients, ignored.
    06:39:48 Sending email for trigger: Always
    06:39:48 ERROR: Error accessing files to attach: Expecting Ant GLOB pattern, but saw ‘/var/lib/jenkins/workspace/testFreeStyle/extentReportFile.html’. See for syntax
    06:39:48 ERROR: Error accessing files to attach: Expecting Ant GLOB pattern, but saw ‘/var/lib/jenkins/workspace/testFreeStyle/extentReportFile.html’. See for syntax
    06:39:48 Sending email to: ***
    06:39:49 Finished: FAILURE


  23. Hi Vj,

    As per your blog, i have configured email, jenkins triggering email but i am not receiving emails,

    Email was triggered for: Success
    Sending email for trigger: Success
    Sending email to:
    Finished: SUCCESS


    • Hi VJ,

      As per your blog, I have configured all the settings in Advanced settings under Editable Email notification, In the console out put it is showing email successfully triggered but i am not receiving email How ever I am able to receive email through Email notification.

      Can you help me asap.



  24. Hi VJ,

    I have configured all the steps as above. but when i get mail on build failure something like this it is shown:


    Started by user XXX
    Building in workspace
    No emails were triggered.
    [Selenium1] $ cmd /c call C:\Users\Virima\AppData\Local\Temp\jenkins6816648486608600122.bat


    java> -cp bin;lib\* org.testng.TestNG testng.xml
    [TestNG] Running:

    Please help me. I want TestNG Reports should be within the Jenkins Email Notifications




  25. hi i got following error in send mail
    ERROR: Error accessing files to attach: Expecting Ant GLOB pattern, but saw ‘D:\workspace\command\test-output\emailable-report.html


  26. Helpful article.. please update the post for below,

    In point #4:

    ${FILE,path=”relative path to html file”}
    Eg: ${FILE,path=”MyWorkspace/MyProj/test-output/emailable-report.html”}

    above 2 lines should be,

    ${FILE,path=”relative path to html file”}
    Eg: ${FILE,path=”MyWorkspace/MyProj/test-output/emailable-report.html”}

    Double quote for the path value is the difference. When I copied it was not finding the file location, after several attempts.. I changed double quote… and it worked.



  27. Hi, this method works for me! thanks! But in Outlook my report is not showing the screenshots whereas i am able to see in the report in jenkins. any ideas?


  28. Hello,

    this has been very helpful. I am trying to get index.html report with similar syntax. but in email it displays as plain text rather than html page. any feedback would be appreciated.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s