missing pie chart and other elements when display serenity report from jenkins
Asked Answered
I

5

7

Need your help!

I've been working on integrating my automation test to Jenkins. I use Serenity BDD and JBehave. My Serenity report displayed OK when I run my test manually. But, when I integrate the test to Jenkins and try to display the report through Publish HTML Report Plugin, it can't display the pie chart and missing other elements as well.

Any idea how to solve this?

Isaiasisak answered 12/1, 2016 at 10:19 Comment(2)
Did you get it working ? I tried below option but didn't work for meMirabella
Possible duplicate of Jenkins - HTML Publisher Plugin - No CSS is displayed when report is viewed in Jenkins ServerFabulist
H
5

Actually you don't need to downgrade Jenkins. This issue happens because of new content security policy headers that is supported by modern browsers. Correct resolution could be the following (code examples and paths for CentOS 7):

  • Configure content policy headers via Jenkins system property:

    sudo vim /etc/sysconfig/jenkins
    set java options as following:
    JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dhudson.model.DirectoryBrowserSupport.CSP=\"sandbox allow-forms allow-scripts; default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';\""
    # save and exit
    sudo /etc/init.d/jenkins restart
    
  • Install Jenkins CORS Filter Plugin: https://wiki.jenkins-ci.org/display/JENKINS/Cors+Filter+Plugin

  • Setup CORS (Manage Jenkins -> Configure System -> CORS Filter) enter image description here

  • Enjoy results :-)

More details about content security policy: http://content-security-policy.com

Homeostasis answered 9/2, 2016 at 8:54 Comment(2)
On Ubuntu I'm getting error ""/etc/sysconfig/jenkins" E212: Can't open file for writing". please clarifyMirabella
Ubuntu 16.04 under /etc/default/jenkins I set below JAVA_ARGS="-Djava.awt.headless=true -Dhudson.model.DirectoryBrowserSupport.CSP=\"sandbox allow-forms allow-scripts; default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src data:;\"" . This doesn't show embedded screen shots, not getting what may be going wrongMirabella
F
4

I have been also facing the same problem. I used some code in the script console to show Extent Report via HTML plugin, it worked but the pie chart was not visible, then after exploring a lot, finally I also found the following code by which I am also able to view the pie chart in my extent reports. Go into Script Console and run the following code;

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "default-src * 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline';")
Falgoust answered 5/8, 2019 at 15:18 Comment(2)
Apply this solution upon a Jenkins 2.346.1 running on Ubuntu and solves the problem immediately. Just to quote for going into the Script Console: Manage Jenkins > Manage Nodes, and in the left menu will appears the Script Console itemLvov
@JRod, in Jenkins 2.346.1 the variable might have changed to "JAVA_OPTS" https://mcmap.net/q/168844/-jenkins-content-security-policyFoist
M
3

I got it working as below on Ubuntu 16.04

  1. Goto /etc/default/jenkins and set below value

    JAVA_ARGS="-Djava.awt.headless=true -Dhudson.model.DirectoryBrowserSupport.CSP=\"sandbox allow-forms allow-scripts; default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src data:;\""

  2. Restart jenkins with command

    http://localhost:8080/safeRestart

  3. Goto Jenkins > Manage Jenkins > Script Console run below

    System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

  4. Close existing Jenkins browser window and open new one in incognito mode.

  5. References

    Jenkins Content Security Policy

    Jenkins - HTML Publisher Plugin - No CSS is displayed when report is viewed in Jenkins Server

Mirabella answered 14/2, 2018 at 16:56 Comment(0)
L
0

Since it is a Java property at the end, it could be setup either inside of the Jenkins application or at the Jenkins starting. In my case using Ubuntu, to add it needs to edit /usr/lib/systemd/system/jenkins.service and add the following line:

# Arguments for display Thucydes Reports correctly
Environment="JAVA_OPTS=-Dhudson.model.DirectoryBrowserSupport.CSP=\"default-src \"*\" 'unsafe-inline' 'unsafe-eval'; script-src \"*\" 'unsafe-inline' 'unsafe-eval'; connect-src \"*\" 'unsafe-inline'; img-src \"*\" data: blob: 'unsafe-inline'; frame-src \"*\"; style-src \"*\" 'unsafe-inline';\""

Save the file and execute the following commands to finish the process:

sudo systemctl daemon-reload
sudo service jenkins restart

Now every time Jenkins is restarted the property is set !

Lvov answered 13/12, 2022 at 21:56 Comment(0)
I
-2

Solved. Need to downgrade Jenkins.

Isaiasisak answered 27/1, 2016 at 11:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.