问题
Publishing Extent Reports in Jenkins using HTML Published Plugin, the results do not display in a proper format.
To resolve this issue, running this command in the Script Console, it started working fine:
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';")
Once Jenkins is restarted, the same issue happened. In this case, I have to use this code each time. Please guide me on how can I set up the code permanently.
回答1:
When you run such commands in the script console they only affect the running session and will be lost on a restart reverting to the stored settings /configuration.
There are various options available to you make them "permanent", depending on how you launch your Jenkins and what's most convenient to you.
This post describes setting them as JENKINS_JAVA_OPTIONS in the jenkins script.
You can pass them in as command line options in the java launch command as shown in the top of the Features controlled by system properties (Make sure to pass all of these arguments before the -jar argument, otherwise they will be ignored).
You can use a groovy Post-initialization script. in ${JENKINS_HOME}/init.groovy or a file in ${JENKINS_HOME}/init.groovy.d/*.groovy
You should bear in mind, changing the CSP settings potentially exposes your Jenkins instance to external risks - READ UP. While the Jenkins code has been recently strengthened to make it more secure, there's a lot of exposure left, especially in the myriad of plugins out there. You should only allow the minimum amount needed to get the plugin working.
It would be nice if the various plugin providers detailed exactly what must be allowed to have their plugin working properly and still keep Jenkins as secure as possible. Consider raising a ticket at http://issues.jenkins-ci.org/ against the plugin in question.
来源:https://stackoverflow.com/questions/57362137/how-to-permanently-resolve-html-publisher-plugin-issue-in-jenkins-showing-extent