The HTML Publisher plugin can be installed from any Jenkins installation connected to the Internet using the Plugin Manage screen. Once installed, the plugin can be configured as part of your Jenkins Freestyle job, or used in a Jenkins Pipeline.
If you use the TestComplete Support plugin to run TestComplete tests with Jenkins, after the build run is over, the plugin will publish test results to Jenkins automatically. You can view them on the build results page.
Figured out the issue. Sharing it here for other users.
CSS is stripped out because of the Content Security Policy in Jenkins. (https://wiki.jenkins-ci.org/display/JENKINS/Configuring+Content+Security+Policy)
The default rule is set to:
sandbox; default-src 'none'; img-src 'self'; style-src 'self';
This rule set results in the following:
To relax this rule, go to
click Script console on left and type in the following command:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
and Press Run. If you see the output as 'Result:' below "Result" header then the protection disabled. Re-Run your build and you can see that the new HTML files archived will have the CSS enabled.
In CentOs, to enable images in html report
sudo vi /etc/sysconfig/jenkins
JENKINS_JAVA_OPTION
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dhudson.model.DirectoryBrowserSupport.CSP=\"default-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' 'unsafe-inline' data:;\""
This will work even after restarting jenkins' server.
Directive
default-src: The default-src is the default policy for loading content such as JavaScript, Images, CSS, Fonts, AJAX requests, Frames, HTML5 Media
img-src: Defines valid sources of images.
Source Value
' self ' - Allows loading resources from the same origin (same scheme, host and port).
Usage :
default-src 'self'
' unsafe-inline ' - Allows use of inline source elements such as style attribute, onclick, or script tag bodies (depends on the context of the source it is applied to) and javascript: URIs.
Usage :
default-src 'unsafe-inline'
' unsafe-eval ' - Allows unsafe dynamic code evaluation such as JavaScript eval()
Usage :
default-src 'unsafe-eval'
data: - Allows loading resources via the data scheme (eg Base64 encoded images).
Usage :
img-src 'self' data:
Please refer more about content security policy here
Go to “Manage Jenkins” -> “Script console” and run below command:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
(The following solution is for Windows.)
A permanent fix is to change a line in [Jenkins directory]\jenkins.xml
(for me it's at C:\Jenkins\jenkins.xml
)
<executable>java.exe</executable>
<arguments>[arguments are here]</arguments>
Add the following argument to the whitespace-separated list of arguments:
-Dhudson.model.DirectoryBrowserSupport.CSP=
Then restart the Jenkins service to pick up the change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With