Home >Web Front-end >CSS Tutorial >Why is My CSS Styling Not Displaying in Jenkins HTML Publisher Reports?
Addressing the CSS Display Issue in Jenkins HTML Publisher
When using the Jenkins HTML Publisher plugin, users may encounter a situation where CSS styling applied to reports doesn't display in Jenkins. However, the styling is visible when the report is viewed locally. This discrepancy arises due to a content security policy setting in Jenkins that restricts the display of CSS from external sources.
The default Content Security Policy in Jenkins is set to:
sandbox; default-src 'none'; img-src 'self'; style-src 'self';
This policy prevents inline CSS and CSS from other websites from being displayed in reports. To resolve this issue and allow CSS to be rendered, users need to relax this policy.
To do so, follow these steps:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
Once the above changes are implemented, users can re-run their builds. New HTML reports will have CSS styling enabled, allowing the intended formatting to be displayed when viewed in Jenkins.
The above is the detailed content of Why is My CSS Styling Not Displaying in Jenkins HTML Publisher Reports?. For more information, please follow other related articles on the PHP Chinese website!