使用 Jenkins html 发布者发布 newman-reporter-html 额外报告失败
Publishing newman-reporter-htmlextra reports with Jenkins html publisher fails
我是运行newman with newman-reporter-htmlextra in a Jenkins pipeline
, generating a html report which I want to publish via the jenkins html publisher。
这是我正在使用的管道阶段
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'
]
}
这是 运行,正在我的 Jenkins
项目中创建条目 Newman HTML Reporter
。
但是,当我打开这样的报告时,它是空的,请检查。
有什么想法吗?
非常感谢,
克里斯蒂安
我猜想您在发布 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 插件针对正确的文件夹
像 junit plugin
一样,将 HTML Publisher 插件放入 dir{}
的范围
要轻松找出您在哪个范围内访问的文件夹,您可以 运行 和 echo pwd
。在您的 dir{}
范围内执行一次,在您的插件范围内执行一次,那么应该清楚您的插件的 reportDir
是错误的。
我是运行newman with newman-reporter-htmlextra in a Jenkins pipeline
, generating a html report which I want to publish via the jenkins html publisher。
这是我正在使用的管道阶段
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'
]
}
这是 运行,正在我的 Jenkins
项目中创建条目 Newman HTML Reporter
。
但是,当我打开这样的报告时,它是空的,请检查
有什么想法吗?
非常感谢, 克里斯蒂安
我猜想您在发布 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 插件针对正确的文件夹
像
junit plugin
一样,将 HTML Publisher 插件放入
dir{}
的范围
要轻松找出您在哪个范围内访问的文件夹,您可以 运行 和 echo pwd
。在您的 dir{}
范围内执行一次,在您的插件范围内执行一次,那么应该清楚您的插件的 reportDir
是错误的。