Home >Web Front-end >CSS Tutorial >Why is My CSS Not Displaying in My Jenkins HTML Publisher Report?

Why is My CSS Not Displaying in My Jenkins HTML Publisher Report?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-22 13:05:12881browse

Why is My CSS Not Displaying in My Jenkins HTML Publisher Report?

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:

  1. Navigate to "Manage Jenkins" and select "Manage Nodes."
  2. Click on the "Settings" (gear) icon.
  3. In the Script console on the left, enter the following command:

    System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
  4. Click "Run."
  5. If the command executes successfully, the output should display "Result:" below the "Result" header.

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!

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