0

I want to see the names of all failed tests in email body when an email is triggered by jenkins using editable email notification plugin.

I am using TestNg with selenium+java.

chirag25
  • 65
  • 2
  • 13
  • try this https://stackoverflow.com/questions/15197682/testng-how-to-send-emailable-report-as-an-email – murali selenium Aug 27 '19 at 12:33
  • Thanks murali for reply : Above link suggestions I have tried earlier but it creates a messy email body with lots of contents..I want that all failed tests names should come in email body. – chirag25 Aug 28 '19 at 04:51

1 Answers1

0

You can add allure reports in your tests and send the allure links or file via emial as in code below:

 stage('Create properties file for allure') {
            steps { 
                sh '''
               export CHATBOT_ENV 
                touch allure-results/environment.properties

               '''   
         }
     } 

        stage('Allure reports') {
            steps { 
              script {
                    allure([
                        includeProperties: true,
                        jdk: '',
                        properties: [],
                        reportBuildPolicy: 'ALWAYS',
                        results: [[path: 'allure-results/']]
                    ])
              }   
            }  
        }

    }
post
        {
        always
        {
            echo 'This will always run'
            emailext body: "Build URL: ${BUILD_URL}",
             attachmentsPattern: "**/path_to_your_report",
            subject: "$currentBuild.currentResult-$JOB_NAME",
            to: 'nobody@optum.com'
        }
    }

}

THe build URL can be used to navigate to allure report.

10raw
  • 506
  • 12
  • 26
  • Thanks for replying Dasra,I am using TestNG as reporting tool,so is there a way to to show show failed tests name in email body with TestNG framework instead of allure... – chirag25 Aug 28 '19 at 04:53
  • You can try to add TestNG as I have used allure. by following the this [link]( https://www.softwaretestingmaterial.com/generate-testng-reports-using-jenkins/ ) and while sending an email you can include attachement as follows:emailext body: "Build URL: ${BUILD_URL}", or the email in the link can be modified to link to the TestNG results link attachmentsPattern: "**/testing-results.xml", subject: "$currentBuild.currentResult-$JOB_NAME", to: 'nobody@optum.com' – 10raw Aug 28 '19 at 15:57