Jenkins 未生成测试报告文件

问题描述 投票:0回答:1

我正在使用 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进行测试

node.js jenkins junit
1个回答
0
投票

如果您在 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
© www.soinside.com 2019 - 2024. All rights reserved.