Home >Web Front-end >CSS Tutorial >Why Won't My CSS Display in Jenkins HTML Publisher Plugin Reports?

Why Won't My CSS Display in Jenkins HTML Publisher Plugin Reports?

Susan Sarandon
Susan SarandonOriginal
2024-11-09 05:38:03515browse

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:

  1. Navigate to "Manage Jenkins" within the Jenkins dashboard.
  2. Select "Manage Nodes."
  3. Click on the "settings" icon (gear icon).
  4. On the left-hand navigation, select "Script console."
  5. Enter the following command in the console:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
  1. Click "Run."
  2. A successful execution will output "Result:" followed by a blank line indicating that the CSP protection has been disabled.

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn