Jenkins - HTML Publisher插件构建失败,报告目录不存在。

3
我正在使用HTML发布插件,并生成HTML报告并将其放置在报告文件夹report/profile.html中。我已经指定了我的报告所在的HTML目录路径进行存档。我将路径指定为/apps/cmjenkins/workspace/service_testapps_copy/LISA Project/Mezzo_Automation/Reports。这导致出现目录不存在错误,因此也给出了完整路径:C:/Users/dtiker/Documents/Feb24/universe1_0_testapps/service_testapps/LISA Project/Mezzo_Automation/Reports 下面是我运行Jenkins构建后控制台输出中看到的错误信息。
12:45:34 [htmlpublisher] Archiving HTML reports...
12:45:34 [htmlpublisher] Archiving at PROJECT level C:/Users/dtiker/Documents/Feb24/universe1_0_testapps/service_testapps/LISA Project/Mezzo_Automation/Reports to /var/lib/jenkins/jobs/API_PROFILE_HTML_Report_POC/htmlreports/HTML_Report
12:45:34 ERROR: Specified HTML directory 'C:/Users/dtiker/Documents/Feb24/universe1_0_testapps/service_testapps/LISA Project/Mezzo_Automation/Reports' does not exist.
12:45:34 Build step 'Publish HTML reports' changed build result to FAILURE
12:45:34 Finished: FAILURE

我验证了该目录确实存在。有人可以告诉我哪里出了问题吗?

1
你能试试使用相对路径来访问文件吗? - Peter Reid
相对路径无法工作,所以使用了绝对路径。 - user2864458
每次构建时,您可能不会拥有相同的工作区目录。 - Peter Reid
有什么想法可以解决这个问题吗?我应该在目录路径中输入什么? - user2864458
@user2864458 看看我的回答,或许可以帮到你:https://stackoverflow.com/a/54203222/5770004 - Gavriel Cohen
3个回答

1
在我的情况下,HTML发布器的配置错误导致了问题。
publishHTML([
  allowMissing: false,
  alwaysLinkToLastBuild: false,
  includes: '**/*.png',     <--------------------- this line
  keepAll: true,
  reportDir: 'reports/',
  reportFiles: 'friday_health_broker_portal_uat_index.html',
  reportName: 'HTML Report',
  reportTitles: 'FH BP'
 ])

当我把 includes 改为 includes: '**/*' 时,问题就解决了


1

你的工作(每个node{})将使用自己的工作空间,你应该始终使用相对路径引用当前构建的文件!

publishHTML(reportDir: 'reports', reportFiles: 'profile.html'])

1
我知道这条评论来得有点晚,但我卡在了这个问题上。你能详细说明一下吗?我也遇到了同样的问题。 - Travis Tubbs
1
你需要确保在同一个“节点”/“代理”中调用发布步骤。 - Christopher
是的,我弄明白了。我的 Mocha 报告没有放在 HTML 发布器查找的同一位置。这是一个初学者的错误。 - Travis Tubbs
我也遇到了这个问题,我能够在该目录中看到JSON文件,它正在使用该节点的工作区(在此处使用docker-agents),但文件是root:bin权限。甚至尝试了chown所有文件和文件夹,仍然出现找不到文件夹的错误。在这里使用相对路径。 - holms

0

当我在“filepath”中使用文件路径而不是'filepath'时,它对我来说运行良好

stage ('publish results') {
      publishHTML([
          allowMissing: false, 
          alwaysLinkToLastBuild: true, 
          keepAll: false, 
          reportDir: "/var/lib/jenkins/workspace/project/target/site/serenity", 
          reportFiles: "index.html", 
          reportName: 'HTML Report', 
          reportTitles: ''
          ])
}

很有帮助!谢谢 :) - Sveta Fishka

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接