HTML Publisher Plugin in Jenkins: Troubleshooting Missing CSS Display
When utilizing the HTML Publisher plugin within Jenkins, users may encounter an issue where CSS formatting intended for report enhancement is not displayed upon viewing in the Jenkins Server. However, when the report is downloaded locally, the CSS formatting appears as intended.
Understanding the Cause:
The absence of CSS in Jenkins is a consequence of the server's Content Security Policy (CSP), which sets stringent restrictions on allowed script sources, plugins, inline or cross-origin CSS, images, frames, and web fonts. The default CSP configuration disallows these elements to ensure enhanced security.
Resolving the Issue:
To mitigate this issue and enable CSS for your HTML reports:
In the Script console on the left, enter the following command:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
Confirming the Fix:
After executing the command, re-run your build. Upon successful completion, the archived HTML files should now display the intended CSS formatting when viewed in the Jenkins Server.
Additional Considerations:
By relaxing the CSP rule, you may potentially undermine the enhanced security provided by Jenkins. It is recommended to consider the potential risks associated with this change and adjust your settings accordingly.
The above is the detailed content of Why is My CSS Not Displaying in My Jenkins HTML Publisher Report?. For more information, please follow other related articles on the PHP Chinese website!