【问题标题】:Writing test result xml file to be read by Jenkins编写测试结果 xml 文件以供 Jenkins 读取
【发布时间】:2017-03-08 14:04:12
【问题描述】:

我的程序使用自定义测试框架,但按照此处所述的 JUnit XML 格式将测试结果保存到 XML 文件:JUnit XML format specification that Hudson supports。 Jenkins 能够使用 xunit 插件按预期解析文件,并显示信息丰富的测试结果。但是,它仅在我进行手动构建和测试结果文件的 git add/commit 时才能看到该文件。我需要做什么才能让 Jenkins “看到”在管道执行期间创建的结果文件?

这是我的 Jenkins 文件:

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                sh 'xcodebuild -scheme UnitTestRunner -configuration debug'
            }
        }
        stage('Test') {
            steps {
                sh 'xcodebuild -scheme UnitTestRunner -configuration debug || true'
                junit '**/TestResults.xml'
            }
        }
    }
}

【问题讨论】:

    标签: git jenkins automated-tests jenkins-pipeline


    【解决方案1】:

    要使测试结果可用于其他阶段,甚至从其他应用程序(例如测试管理工具)下载它们,您需要将它们发布为工件:

    stage('Test') {
                steps {
                    sh 'xcodebuild -scheme UnitTestRunner -configuration debug || true'
                    junit '**/TestResults.xml'
                    archiveArtifacts artifacts: '**/TestResults.xml'
                }
            }
    

    【讨论】:

      【解决方案2】:

      您应该检查结果文件是否在您的工作区中生成。检查工作区本身或使用archiveArtifacts 归档所有文件。然后你只需要为文件定义正确的模式。确保您在同一 nodestash 中有结果文件,以便稍后在另一个节点中发布。

      【讨论】:

        猜你喜欢
        • 2021-08-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-02-02
        • 1970-01-01
        • 1970-01-01
        • 2015-01-01
        • 1970-01-01
        相关资源
        最近更新 更多