尝试使用Jenkins管道进行构建时收到以下错误消息。它说它无法找到报告文件。但根据我的理解,在执行测试时是否应该生成这些报告文件?在本地我可以使用mvnw clear test运行测试,并在目标文件夹(Maven Project)中生成文件。由于目标文件夹包含构建文件,我不假设我必须将这些文件上传到git Repo? 对于任何形式的帮助,我都会非常开心!
Jenking Build Failure:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Error: Invalid or corrupt jarfile /var/lib/jenkins/jobs/tool Job/workspace/target/surefire/surefirebooter1117922841156378420.jar
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.507 s
[INFO] Finished at: 2017-10-07T15:21:53Z
[INFO] Final Memory: 58M/398M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project j-hipster-irp: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd "/var/lib/jenkins/jobs/tool Job/workspace" && /usr/lib/jvm/java-8-openjdk/jre/bin/java '-javaagent:/var/lib/jenkins/.m2/repository/org/jacoco/org.jacoco.agent/0.7.9/org.jacoco.agent-0.7.9-runtime.jar=destfile=/var/lib/jenkins/jobs/tool Job/workspace/target/test-results/coverage/jacoco/jacoco.exec' -Djava.security.egd=file:/dev/./urandom -Xmx256m -jar '/var/lib/jenkins/jobs/tool Job/workspace/target/surefire/surefirebooter1117922841156378420.jar' '/var/lib/jenkins/jobs/tool Job/workspace/target/surefire/surefire1734872125374791310tmp' '/var/lib/jenkins/jobs/tool Job/workspace/target/surefire/surefire_03108578491450238058tmp'
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[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
Jenkins文件包含:
#!/usr/bin/env groovy
node {
stage('checkout') {
checkout scm
}
stage('check java') {
sh "java -version"
}
stage('clean') {
sh "chmod +x mvnw"
sh "./mvnw clean"
}
stage('install tools') {
sh "./mvnw com.github.eirslett:frontend-maven-plugin:install-node-and-yarn -DnodeVersion=v6.11.3 -DyarnVersion=v1.1.0"
}
stage('yarn install') {
sh "./mvnw com.github.eirslett:frontend-maven-plugin:yarn"
}
stage('backend tests') {
try {
sh "./mvnw test"
} catch(err) {
throw err
} finally {
junit '**/target/surefire-reports/TEST-*.xml'
}
}
stage('frontend tests') {
try {
sh "./mvnw com.github.eirslett:frontend-maven-plugin:yarn -Dfrontend.yarn.arguments=test"
} catch(err) {
throw err
} finally {
junit '**/target/test-results/karma/TESTS-*.xml'
}
}
stage('packaging') {
sh "./mvnw package -Pprod -DskipTests"
archiveArtifacts artifacts: '**/target/*.war', fingerprint: true
}
答案 0 :(得分:0)
JUnit Jenkins plugin有一个标志,允许空测试结果:
allowEmptyResults
(可选) 如果选中此选项,则将更改在缺少测试结果文件或测试结果为空的情况下无法通过构建的默认行为,以不影响构建的状态。请注意,此设置将使得在不生成测试报告文件时测试工具未显示错误代码的情况下,更难发现配置错误的作业或构建失败。