我在Jenkins pipeline
中将newman与newman-reporter-htmlextra一起运行,生成了一个我想通过jenkins html publisher发布的html报告。
这是我正在使用的管道中的阶段
stage('Newman tests') {
steps() {
script {
dir("${JENKINS_HOME}/workspace/myproject") {
sh 'newman run "./Collections/my_collection.postman_collection.json" --reporters cli,junit,htmlextra --reporter-junit-export "newman_result.xml" --reporter-htmlextra-export "newman_result.html"'
junit "*.xml"
}
}
publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: '.',
reportFiles: 'newman_result.html',
reportName: 'Newman HTML Reporter'
]
}
它正在运行,并在我的Newman HTML Reporter
项目中创建条目Jenkins
。
有什么想法吗?
非常感谢, 基督徒
答案 0 :(得分:1)
我想您要发布html结果时访问的文件夹错误。 您正在不在常规的jenkins工作区中创建文件:
dir("${JENKINS_HOME}/workspace/myproject") {
sh 'newman run "./Collections/my_collection.postman_collection.json" --reporters cli,junit,htmlextra --reporter-junit-export "newman_result.xml" --reporter-htmlextra-export "newman_result.html"'
junit "*.xml"
}
离开script{}
后,您将访问Jenkins的原始工作区,因此reportDir: '.'
与文件所在的文件夹不同,这意味着没有文件=无法显示html。
您在这里有3个选择:
您可以在Jenkins的常规工作区中创建文件
HTML Publisher插件的目标是正确的文件夹
将HTML Publisher插件放入dir{}
的范围内,就像处理junit plugin
要轻松找出要访问哪个文件夹的范围,可以运行echo pwd
。一次在您的dir{}
范围内执行一次,一次在您的插件范围内执行一次,那么应该清楚您插件的reportDir
是错误的。