原文链接 问题描述 对于测试报告来说,除了内容的简洁精炼,样式的美观也很重要。常用的做法是,采用 HTML 格式的文档,并搭配 CSS 和 JS ,实现自定义的样式和动画效果(例如展开、折叠等)。 在 Jenkins 中要展示 HTML 文档,通常采用的方式有两种: 使用 HTML Publisher Plugin ; 使用 Files to archive 功能,在 Build Artifacts 中显示 HTML 文档链接。 第一种方式配合插件,可以通过图形化操作实现简易配置,并且展示效果也不错;而第二种方式的优势在于使用 Jenkins 自带的功能,不依赖插件也能实现基本的需求。 然而,不管是采用哪种方式,都有可能会遇到一种情况,就是展示出来的 HTML 报告样式全无。在浏览器的 Network 中查看资源加载情况,会发现相关的 CSS 和 JS 都没法正常加载。 1 2 3 4 Refused to load the stylesheet 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css' because it violates the following Content Security Policy directive: "style-src 'self'". Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-0EZqoz+oBhx7gF4nvY2bSqoGyy4zLjNF+SDQXGp/ZrY='), or a nonce ('nonce-...') is required to enable inline execution. Blocked script execution in 'http://10.13.0.146:8888...