Configure Jenkins CSP for Ubuntu Service

I upgraded to v2.2 of Jenkins on my server and I want to relax the new Content Security Policy configuration. I can successfully run

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

which temporarily sets the value and make the HTML output display properly. However when I restart Jenkins the value needs to be changed again. The web page says to run

java -Dhudson.model.DirectoryBrowserSupport.CSP= -jar jenkins.war

however the only file is located at /usr/share/jenkins/jenkins.war and when I run the command on that file it tries to setup a new Jenkins instance.

Is there a different file or way to run this command for an Ubuntu service?

2

2 Answers

To run Jenkins every time you restart the server with the option to relax the content security policy, run it as a service with the options you require.

  1. Download jenkins.war file to any convenient destination, eg. /home/jenkins_user
  2. Create service file /etc/systemd/system/jenkins.service specifying the relaxed security policy
  3. Reload service manager: systemctl daemon-reload
  4. That's it! Now manage the service

Full instructions including examples are given here Installing Jenkins as a Linux Daemon

1

I ended up modifying /etc/default/jenkins. There should be a line that sets a JAVA_ARGS variable. I copied -Dhudson.model.DirectoryBrowserSupport.CSP= a described on the jenkins website into that variable.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like