如何在并行jenkins管道中生成聚合宁静测试报告

时间:2018-05-27 08:29:29

标签: jenkins

我们正在为多样性测试场景并行运行Jenkins声明性管道,并使用宁静来生成测试报告。目前,我们应该根据具体的测试场景检查不同的测试报告(例如,10个测试场景和10个平静报告)。现在我们只想生成1个汇总报告。如何在管道中配置?如果您需要更多信息,请回复我。感谢任何人的帮助。

pipeline {
agent { node ("cm-linux") }
stages {
    stage('run-parallel-regression-testing') {
        steps {
            parallel(
                Run1_LoginPage: {
                  node('cm-windows'){
                  withEnv(["JAVA_HOME=${tool '1.8.0.65_Windows'}", "PATH+MAVEN=${tool 'maven-3.0.4'}/bin"]){
                    deleteDir()
                    checkout([$class: 'GitSCM',
                    branches: [[name: '*/Ted']],
                    doGenerateSubmoduleConfigurations: false,
                    extensions: [],
                    gitTool: 'GIT_windows',
                    submoduleCfg: [],
                    userRemoteConfigs: [[credentialsId: '<Credential>',
                    url: '<GITHUB ADDRESS>']]])
                  bat 'mvn clean -Dtest=Run1_LoginPage -Dwebdriver.remote.url="<seleniumgrid hub address>" verify'
                    publishHTML([allowMissing: false,
                    alwaysLinkToLastBuild: true,
                    keepAll: true,
                    reportDir: 'target\\site\\serenity',
                    reportFiles: 'index.html',
                    reportName: 'Run1_LoginPage'])
                          }
                      }
                  },
                Run2_SearchTab: {
                  node('cm-windows'){
                  withEnv(["JAVA_HOME=${tool '1.8.0.65_Windows'}", "PATH+MAVEN=${tool 'maven-3.0.4'}/bin"]){
                    deleteDir()
                    checkout([$class: 'GitSCM',
                    branches: [[name: '*/Ted']],
                    doGenerateSubmoduleConfigurations: false,
                    extensions: [],
                    gitTool: 'GIT_windows',
                    submoduleCfg: [],
                    userRemoteConfigs: [[credentialsId: '<credential id>',
                    url: '<github address>']]])
                  bat 'mvn clean -Dtest=Run2_SearchTab -Dwebdriver.remote.url="<seleniumgrid hub address>" verify'
                    publishHTML([allowMissing: false,
                    alwaysLinkToLastBuild: true,
                    keepAll: true,
                    reportDir: 'target\\site\\serenity',
                    reportFiles: 'index.html',
                    reportName: 'Run2_SearchTab'])
                        }
                    }
                },

                Run4_AccountTab: {
                  node('cm-windows'){
                  withEnv(["JAVA_HOME=${tool '1.8.0.65_Windows'}", "PATH+MAVEN=${tool 'maven-3.0.4'}/bin"]){
                    deleteDir()
                    checkout([$class: 'GitSCM',
                    branches: [[name: '*/Ted']],
                    doGenerateSubmoduleConfigurations: false,
                    extensions: [],
                    gitTool: 'GIT_windows',
                    submoduleCfg: [],
                    userRemoteConfigs: [[credentialsId: '<credential id>',
                    url: '<github address>']]])
                  bat 'mvn clean -Dtest=Run4_AccountTab -Dwebdriver.remote.url="<seleniumgrid hub address>" verify'
                    publishHTML([allowMissing: false,
                    alwaysLinkToLastBuild: true,
                    keepAll: true,
                    reportDir: 'target\\site\\serenity',
                    reportFiles: 'index.html',
                    reportName: 'Run4_AccountTab'])
                            }
                        }
                    },
                Run3_CustomerTab: {
                  node('cm-windows'){
                  withEnv(["JAVA_HOME=${tool '1.8.0.65_Windows'}", "PATH+MAVEN=${tool 'maven-3.0.4'}/bin"]){
                    deleteDir()
                    checkout([$class: 'GitSCM',
                    branches: [[name: '*/Ted']],
                    doGenerateSubmoduleConfigurations: false,
                    extensions: [],
                    gitTool: 'GIT_windows',
                    submoduleCfg: [],
                    userRemoteConfigs: [[credentialsId: '<credential id>',
                    url: '<github address>']]])
                  bat 'mvn clean -Dtest=Run3_CustomerTab -Dwebdriver.remote.url="<seleniumgrid hub address>" verify'
                    publishHTML([allowMissing: false,
                    alwaysLinkToLastBuild: true,
                    keepAll: true,
                    reportDir: 'target\\site\\serenity',
                    reportFiles: 'index.html',
                    reportName: 'Run3_CustomerTab'])
                            }
                        }
                    }
            )
        }
    }
}

}

1 个答案:

答案 0 :(得分:0)

在这里看看:https://serenity-bdd.github.io/theserenitybook/latest/serenity-parallel.html#_configuring_parallel_batch_execution_with_jenkins_2_dsl

通过存放部分结果并最后逐个存放它们,您将获得一个文件夹,其中所有测试结果都一起复制了。

此示例中缺少的是聚合步骤。你必须跑 “ MVN宁静:汇总” 在发布报告之前。它将所有单个测试结果合并到概述页面中。