Skip to content

Instantly share code, notes, and snippets.

@cccaternberg
Last active March 4, 2022 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cccaternberg/3b7f0a9a10ed255c99987a2bee925e26 to your computer and use it in GitHub Desktop.
Save cccaternberg/3b7f0a9a10ed255c99987a2bee925e26 to your computer and use it in GitHub Desktop.
hudson.model.DirectoryBrowserSupport.CSP
cd $JENKINS_HOME
mkdir -p init.groovy.d/
#see https://www.jenkins.io/doc/book/managing/groovy-hook-scripts/
#open file with vi
vi init.groovy.d//init.groovy
#add the follwing and save
#init.groovy
import jenkins.model.Jenkins
import hudson.model.*
import java.util.logging.Logger
Logger.global.info("[Running] startup script")
//Properties müssen auf die CAP Gemini properties angepasst werden!
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "default-src 'self'; style-src 'self' 'unsafe-inline';")
System.getProperty("hudson.model.DirectoryBrowserSupport.CSP")
Jenkins.instance.save()
#Exit and save
#chamge owner and permissions
chown -R cloudbees-core-cm.cloudbees-core-cm init.groovy.d/*
chmod a+x init.groovy.d/*
#restart
systemctl restart cloudbees-core-cm
#go to jenkins script console after restart and run
System.getProperty("hudson.model.DirectoryBrowserSupport.CSP")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment