Jenkins html publisher css 問題
注意到在最新的 jenkins 版本(例如 2.19.2)中,html-publisher-plugin 發布的 html 報告的 css 樣式不起作用。
Cause
- This is due to Content Security Policy in Jenkins
- By default the policy is set:
The default rule is set to: sandbox; default-src 'none'; img-src 'self'; style-src 'self';
- which applies:
- 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.
Solution
- Go to "Manage Jenkins" -> "Script console"
- Type and run below command:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
See this stackoverflow for reference: Jenkins - HTML Publisher Plugin - No CSS is displayed when report is viewed in Jenkins Server