27

If I open any .html file that generated by Robot Framework and try to convert it in any other format(for example, docx formate) using either any python code or inbuilt command line tool that are available. I am getting below error,

  1. Opening Robot Framework log failed

• Verify that you have JavaScript enabled in your browser.

• Make sure you are using a modern enough browser. Firefox 3.5, IE 8, or equivalent is required, newer browsers are recommended.

• Check are there messages in your browser's JavaScript error log. Please report the problem if you suspect you have encountered a bug.

· I am getting this error even though I have already enabled JavaScript in my browser.I am using Mozilla Firefox version 45.0.2 on mac.

Can anyone please help me to solve this issue?

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
dharpatel
  • 457
  • 1
  • 6
  • 8
  • So if you save `` in an html file and open it in your browser, you get a pop up saying "hi"? – jDo Apr 13 '16 at 19:11
  • Yes it is showing me pop up.. – dharpatel Apr 14 '16 at 20:49
  • So, you're saying that you have a file generated by robot framework, and when you open that file in a browser you're getting an error? Your question is unclear because the first statement implies you are trying to convert it, and a browser isn't generally used to convert html files. – Bryan Oakley Apr 15 '16 at 15:17
  • Have you found a solution yet? – Tamas G. Oct 06 '16 at 11:51
  • I have the same problem but none of the answers worked for me. – Coliban Jul 29 '21 at 13:20

9 Answers9

47

Answer is explained at Jenkins issue tracking system: https://issues.jenkins-ci.org/browse/JENKINS-32118

To resolve your problem you must :

  1. Connect on your Jenkins URL (http://[IP]:8080/)
  2. Click on Manage Jenkins from left side panel.
  3. Click on Script Console
  4. Copy this into the field
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP","sandbox allow-scripts; default-src 'none'; img-src 'self' data: ; style-src 'self' 'unsafe-inline' data: ; script-src 'self' 'unsafe-inline' 'unsafe-eval' ;")
  1. Click on Run button.

  2. Execute your Jenkins build.

Guy Avraham
  • 3,482
  • 3
  • 38
  • 50
Toral
  • 551
  • 1
  • 5
  • 13
  • 3
    The changes will be lost if or when you restart the server. You need to do it again. It worked in version 2.46.3. – koxta Jul 17 '17 at 17:40
8

I managed to make it work by editing the file /etc/sysconfig/jenkins and adding -Dhudson.model.DirectoryBrowserSupport.CSP= to the JENKINS_JAVA_OPTIONS setting. On my installation, the setting looks like

JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dhudson.model.DirectoryBrowserSupport.CSP= "

Then restart jenkins

service jenkins restart

Sources

https://wiki.jenkins-ci.org/display/JENKINS/Configuring+Content+Security+Policy

System properties management

Community
  • 1
  • 1
Emil Salageanu
  • 997
  • 1
  • 10
  • 24
5

We used to face same issue, however since we did not have access to jenkins, we could do it at client side be installing CSP plugin on chrome and enabling the plugin.

Karthik Prasad
  • 9,662
  • 10
  • 64
  • 112
5

Running below code in Script Console of Manage Jenkins will work

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP","sandbox allow-scripts; default-src 'none'; img-src 'self' data: ; style-src 'self' 'unsafe-inline' data: ; script-src 'self' 'unsafe-inline' 'unsafe-eval' ;")

But whenever you start Jenkins then you have to execute this every time. Instead of this if you use this when you are starting Jenkins by using of batch file with below code then it will be better than this process

java -Dhudson.model.DirectoryBrowserSupport.CSP="sandbox allow-scripts; default-src 'none'; img-src 'self' data: ; style-src 'self' 'unsafe-inline' data: ; script-src 'self' 'unsafe-inline' 'unsafe-eval' ;" -jar jenkins.war
Karthikeya
  • 324
  • 3
  • 10
  • if i give this in jenkins bat Im getting SEVERE: Container startup failed java.io.IOException: Failed to start Jetty – Mia Aug 14 '20 at 13:38
3

The easiest thing to do is (if there are no worries on security aspects) also a permanent fix.

  1. open the jenkins.xml file and

  2. add the following

    <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Dhudson.model.DirectoryBrowserSupport.CSP="" -jar "%BASE%\jenkins.war" -- httpPort=8080 --webroot="%BASE%\war"</arguments>

  3. restart the jenkins server

  4. rerun your jenkins jobs to see the result files.

If we are using the script console, every time you restart the jenkins server, the changes will be lost.

Sajan Jacob K
  • 496
  • 5
  • 8
1

The accepted answer works for me but is not persistent. To make it persistent, modify the file /etc/default/jenkins and after JAVA_ARGS line, add the following line:

JAVA_ARGS="$JAVA_ARGS -Dhudson.model.DirectoryBrowserSupport.CSP=\"sandbox allow-scripts; default-src 'none'; img-src 'self' data: ; style-src 'self' 'unsafe-inline' data: ; script-src 'self' 'unsafe-inline' 'unsafe-eval' ;\""

Change will apply and be persistent after reboot

Katu
  • 1,296
  • 1
  • 24
  • 38
1

For me editing JAVA_ARGS in /etc/default/jenkins didn't work. To make changes permanent on Ubuntu 18.04 LTS when running Jenkins as service I did following:

  1. Run service jenkins status and from second line take path to actual service configuration file, mine was: /lib/systemd/system/jenkins.service
  2. Run sudo vim /lib/systemd/system/jenkins.service find property Environment= under comment Arguments for the Jenkins JVM
  3. Paste: -Dhudson.model.DirectoryBrowserSupport.CSP=\"sandbox allow-scripts; default-src 'none'; img-src 'self' data: ; style-src 'self' 'unsafe-inline' data: ; script-src 'self' 'unsafe-inline' 'unsafe-eval' ;\" behind -Djava.awt.headless=true
  4. Run sudo service jenkins stop, you should see following warning: Warning: The unit file, source configuration file or drop-ins of jenkins.service changed on disk. Run 'systemctl daemon-reload' to reload units.
  5. Run sudo systemctl daemon-reload
  6. Run sudo service jenkins start

You should be now able to browse robot framework results after restart.

Thom
  • 11
  • 1
0

Please follow these steps to configure content security policies around Jenkins should resolve this issue: 1. Go to Jenkins 2. Click on Manage Jenkins 3.Click on Script Console 4.Enter unset header text shown in content security policies: System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

Click Run

The output should just show Result. If you see any thing other than this, that mean content policy is not updated successfully

If you are still facing the issue, please add the error details, what you tried, so we would be able to help you

0

The configuration change persists for me with Jenkins 2.235.2 installed via yum on CentOS 7 by placing the following content in a new file at $JENKINS_ROOT/init.groovy, changing ownership of the file to the jenkins user, and then restarting Jenkins with service jenkins restart

import jenkins.model.Jenkins;
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP","sandbox allow-scripts; default-src 'none'; img-src 'self' data: ; style-src 'self' 'unsafe-inline' data: ; script-src 'self' 'unsafe-inline' 'unsafe-eval' ;");