Jenkins - HTML Publisher插件 - 在Jenkins Server中查看报告时不显示CSS [英] Jenkins - HTML Publisher Plugin - No CSS is displayed when report is viewed in Jenkins Server

查看:1252
本文介绍了Jenkins - HTML Publisher插件 - 在Jenkins Server中查看报告时不显示CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jenkins HTML Publisher插件有一个奇怪的问题,那就是当我在Jenkins中查看时,我添加到报告中的所有花哨的CSS都被剥离了。如果我将报告下载到本地,我可以看到CSS格式。 Jenkins中有一个允许CSS查看的设置吗?



Jenkins中的我的HTML发布者设置:





我的报告页面显示在Jenkins中:

< a href =https://i.stack.imgur.com/4aSHL.png =noreferrer>



我的报告页面显示在本地:

解决方案

找出问题所在。在这里为其他用户共享。



由于Jenkins中的内容安全策略,CSS被剥离出来。 ( https://wiki.jenkins-ci.org/display/ JENKINS /配置+内容+安全+政策



默认规则设置为:

 沙箱; default-src'none'; img-src'self'; style-src'self'; 

此规则集包含以下内容:




  • 完全不允许使用JavaScript
  • 不允许使用插件(object / embed)
  • 没有嵌入式CSS或CSS允许使用其他网站允许其他网站允许使用 允许其他网站允许使用

  • 不允许使用网络字体

  • 不允许使用XHR / AJAX等。



,转到Manage Jenkins-> Script console并输入以下命令:

  System.setProperty(hudson.model.DirectoryBrowserSupport .CSP,)

并按运行。如果在结果标题下看到输出为结果:,则保护被禁用。重新运行你的构建,你可以看到归档的新HTML文件将启用CSS。


I have a strange problem with the Jenkins HTML Publisher plugin, wherein all the fancy CSS I have added to the report is stripped out when viewed in Jenkins. If I download the report to local, I am able to see the CSS formatting. Is there a setting in Jenkins which allows CSS to be viewed?

My HTML Publisher Settings in Jenkins:

My Report Page when displayed in Jenkins :

My Report Page when displayed in Local :

解决方案

Figured out the issue. Sharing it here for other users.

CSS is stripped out because of the Content Security Policy in Jenkins. (https://wiki.jenkins-ci.org/display/JENKINS/Configuring+Content+Security+Policy)

The default rule is set to:

sandbox; default-src 'none'; img-src 'self'; style-src 'self';

This rule set results in the following:

  • No JavaScript allowed at all
  • No plugins (object/embed) allowed
  • No inline CSS, or CSS from other sites allowed
  • No images from other sites allowed
  • No frames allowed
  • No web fonts allowed
  • No XHR/AJAX allowed, etc.

To relax this rule, go to Manage Jenkins->Script console and type in the following command:

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

and Press Run. If you see the output as 'Result:' below "Result" header then the protection disabled. Re-Run your build and you can see that the new HTML files archived will have the CSS enabled.

这篇关于Jenkins - HTML Publisher插件 - 在Jenkins Server中查看报告时不显示CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆