Home >Web Front-end >CSS Tutorial >Why Won't My CSS Display in Jenkins HTML Publisher Plugin Reports?
CSS Display Issue with Jenkins HTML Publisher Plugin
When utilizing the Jenkins HTML Publisher plugin, users may encounter a problem where the CSS formatting is not displayed when viewing the report within Jenkins. However, when the report is downloaded locally, the intended CSS styles appear as expected.
Analysis
This issue arises due to the stringent Content Security Policy (CSP) implemented by Jenkins. The default CSP rule prohibits inline CSS, as well as CSS from external sources. Hence, any CSS included in the HTML report is stripped out during display in Jenkins.
Solution
To resolve this issue, it is necessary to relax the CSP rules to allow inline CSS. This can be achieved by following these steps:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
After performing these steps, re-run the build process. The newly archived HTML files should now have CSS enabled, resulting in the expected visual presentation of the report both in Jenkins and when viewed locally.
The above is the detailed content of Why Won't My CSS Display in Jenkins HTML Publisher Plugin Reports?. For more information, please follow other related articles on the PHP Chinese website!