Cobertura Report Not showing css properly

Recently I setup Cobertura reports showing coverage report in my jenkins which was getting generated from gocov, but I noticed that it wasn’t showing the properly CSS and everything was in plan old text. When i investigated using the Developer console, I found out that browser was blocking the in-line css due to content security policies. I was seeing following errors.

Blocked script execution in '<https://jenkins_url_here>' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.</code>

After searching I found out Configuring Content Security Policy article which talks about Jenkins content security policy settings.

As I was using Debian box to run jenkins, I had to update /etc/default/jenkins file and update JAVA_ARGS variables and add the following into it. Restart Jenkins for changes to take effect.

vi /etc/default/jenkins

-Dhudson.model.DirectoryBrowserSupport.CSP="default-src 'self'; style-src 'self' 'unsafe-inline';" 

systemctl restart jenkins

And my cover reports were loading properly after this with all the CSS, etc.,

– Sandeep Sidhu

w