使用Jenkins管道在Jenkins控制台上打印失败的测试数据

2w3kk1z5  于 2023-06-21  发布在  Jenkins
关注(0)|答案(1)|浏览(181)

我找不到任何方法来打印失败的测试标签,测试名称,原因等机器人框架的结果在Jenkins控制台使用机器人插件或通过解析output.xml
正如ChatGPT建议的那样,我尝试将output.xml输入到jenkins管道中的机器人插件的robot()中。但我没有得到这样的财产失败测试

pipeline {

    agent any

    stages {

        stage('Robot Test') {

            steps {

                script {

                    // Run Robot Framework tests

                    sh 'robot --outputdir results tests'

                    // Parse the Robot Framework output XML file

                    def robotOutput = robot(

                        inputFile: 'results/output.xml',

                        outputPath: 'robot-reports',

                        logFileName: 'log.html',

                        reportFileName: 'report.html',

                        outputFileName: 'output.xml'

                    )

                    // Print failed tags

                    robotOutput.failedTests.each { failedTest ->

                        failedTest.tags.each { tag ->

                            println("Failed tag: ${tag}")

                        }

                    }

                }

            }

        }

    }

}
d5vmydt9

d5vmydt91#

最简单的方法是使用junit插件:https://plugins.jenkins.io/junit/示例:

dir ("app/test-results") {
      junit allowEmptyResults: true, skipPublishingChecks: true, testResults: '*'
 }

相关问题