首页 > 解决方案 > 有没有办法通过詹金斯在电子邮件正文中显示失败测试的名称

问题描述

当詹金斯使用可编辑的电子邮件通知插件触发电子邮件时,我想在电子邮件正文中查看所有失败测试的名称。

我正在将 TestNg 与 selenium+java 一起使用。

标签: jenkinsselenium-webdrivertestngjenkins-plugins

解决方案


您可以在测试中添加魅力报告,并通过 emial 发送魅力链接或文件,如下代码所示:

 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'
        }
    }

}

构建 URL 可用于导航到诱惑报告。


推荐阅读