首页 > 代码库 > 解决在jenkins中无法打开robot framework report.html log.html的问题

解决在jenkins中无法打开robot framework report.html log.html的问题

问题描述:

Opening Robot Framework report failed

  • Verify that you have?JavaScript enabled?in your browser.
  • Make sure you are using a?modern enough browser. Firefox 3.5, IE 8, or equivalent is required, newer browsers are recommended.
  • Check are there messages in your browser‘s?JavaScript error log. Please report the problem if you suspect you have encountered a bug.

??

来自 <http://localhost:8080/job/robot%E6%B5%8B%E8%AF%95/8/robot/report/report.html>

??

??

技术分享

之前,用的还好好的,为什么现在的报告(reporter.html,log.html)打不开了呢?

??

出现这个问题的原因是:你升级了jenkins造成的。据官方说明:

??

Jenkins 1.641 / Jenkins 1.625.3 introduce the Content-Security-Policy header to static files served by Jenkins (specifically, DirectoryBrowserSupport). This header is set to a very restrictive default set of permissions to protect Jenkins users from malicious HTML/JS files in workspaces, /userContent, or archived artifacts.

jenkins增加的内容安全策略,默认情况下,是禁止执行javascript,css等资源的。

技术分享

??

那么如何解决呢?

??

找到jenkins的安装目录下的jenkins.xml,修改此文件

修改前

??

<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080</arguments>

??

修改后

??

<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Dhudson.model.DirectoryBrowserSupport.CSP="default-src ‘self‘; script-src ‘self‘ ‘unsafe-inline‘ ‘unsafe-eval‘; style-src ‘self‘ ‘unsafe-inline‘; img-src ‘self‘ ‘unsafe-inline‘;" -jar "%BASE%\jenkins.war" --httpPort=8080</arguments>

??

一定要重启jenkins,最好能再执行一下测试脚本,让它生成新的报告文件就行了。

??

参考链接:

??

https://groups.google.com/forum/#!msg/concordion/RSp92D2CNuc/nwYW4yqvEQAJ

https://kb.froglogic.com/display/KB/Content+Security+Policy+(CSP)+for+Web+Report

??

解决在jenkins中无法打开robot framework report.html log.html的问题