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

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

问题描述

我对 Jenkins HTML Publisher 插件有一个奇怪的问题,其中我添加到报告中的所有花哨 CSS 在 Jenkins 中查看时都被删除了.如果我将报告下载到本地,我可以看到 CSS 格式.Jenkins 中是否有允许查看 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?

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

My HTML Publisher Settings in Jenkins:

我的报告页面在 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.

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

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

默认规则设置为:

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

此规则集的结果如下:

  • 根本不允许使用 JavaScript
  • 不允许使用插件(对象/嵌入)
  • 不允许使用内联 CSS 或来自其他网站的 CSS
  • 没有来自其他人的图片允许的网站
  • 不允许有框架
  • 不允许使用网络字体
  • 不允许使用 XHR/AJAX 等

要放宽此规则,请转到

  1. 管理詹金斯->
  2. 管理节点->
  3. 点击设置(齿轮图标)->
  4. 点击左侧的脚本控制台并输入以下命令:

  1. Manage Jenkins->
  2. Manage Nodes->
  3. Click settings(gear icon)->
  4. click Script console on left and type in the following command:

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

然后按运行.如果您在结果"标题下方看到输出为结果:",则保护被禁用.重新运行您的构建,您可以看到存档的新 HTML 文件将启用 CSS.

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 服务器中查看报告时不显示 CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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