【问题标题】:Jenkins not generating test report files詹金斯没有生成测试报告文件
【发布时间】:2017-08-20 22:14:44
【问题描述】:

我正在使用 pipline 构建和运行单元测试。

这是我的管道:

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                sh '''
                  ./system/fuge/ci/docker-up.sh
                  ./system/fuge/ci/docker-down.sh
                '''
            }
        }

        stage('Test') {
            steps {
                sh '''
                 ./system/fuge/ci/docker-up-test.sh
               '''
            }
        }
}
        post {
        always {
            junit 'build/reports/**/*.xml'
          }
        }

}

我得到了这个错误:

[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] junit
Recording test results
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: No test report files were found. Configuration error?
Finished: FAILURE

有人知道是什么问题吗?

我也使用node.js、lab.js进行测试

【问题讨论】:

  • 当您在 jenkins 之外运行 ./system/fuge/ci/docker-up-test.sh 时,build/reports/**/*.xml 中是否会显示一些 xml 文件?
  • 看起来您的存档文件夹错误,请确保您在特定路径上有一些 xml。您可以在完成后检查运行管道的机器并找到xml,而不是修复存档的命令。
  • 测试报告在我的 docker 容器中,如何访问它们?

标签: node.js jenkins junit lab


【解决方案1】:

如果您在 docker 容器中运行测试,则可以通过将目录绑定到主机(使用 docker-compose 卷)将它们恢复到主机。请注意,这可能会导致奇怪的权限主机上的文件)或在容器内完成测试后运行docker cp,如下所示:

# make sure the directory exists on the host
mkdir -p build/reports

# make sure the directory we want to copy doesn't exist on the host
rm -rf build/reports/something

# copy directory from container to host
docker cp CONTAINER_NAME:build/reports/something build/reports/something

【讨论】:

  • 您能否尝试使用上述两种策略中的一种(均适用于 docker-compose 和 jenkins),如果您无法在几个小时后使其正常工作,请在此处报告?
  • C/P 有效,但我怎样才能动态获取容器名称,以及如何从文件夹中 c/p 所有测试而不仅仅是一个?
  • 检查运行测试时容器名称是什么。它通常很传统(fuge_api_1 或其他东西)。不幸的是,docker-compose 不允许您指定容器名称,因为这对于 CI 用例来说非常方便。我更新了答案以显示如何复制整个目录而不是文件。
  • 好的,当我 C/P 文件现在可以正常工作但我从 Jenkins 收到错误消息:ERROR: Test reports were found but none of them are new. Did tests run? For example, ,,,seneca/test/api.xml is 27 sec old
  • 如果它回答了您的原始问题,请接受。 :)
猜你喜欢
  • 2021-09-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-22
  • 2016-07-27
相关资源
最近更新 更多