From f5fd3034e5b2d1cdad8db6818f47d8f19e1cbcda Mon Sep 17 00:00:00 2001 From: Andy Hibbert Date: Wed, 6 Nov 2019 16:23:25 +0000 Subject: [PATCH] PRE_CLEAR_INIT_GROOVY_D: Change-Id: I79bb00935a8d4a28a5e5f8b24fc70aafbef38695 --- README.md | 2 ++ jenkins.sh | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 7017685d23..bf5aa7587e 100644 --- a/README.md +++ b/README.md @@ -164,6 +164,8 @@ FROM jenkins/jenkins:lts COPY custom.groovy /usr/share/jenkins/ref/init.groovy.d/custom.groovy ``` +If you need to maintain the entire init.groov.d directory and have a persistent JENKINS_HOME you may run the docker image with `-e PRE_CLEAR_INIT_GROOVY_D=true` + ## Preinstalling plugins You can rely on the `install-plugins.sh` script to pass a set of plugins to download with their dependencies. diff --git a/jenkins.sh b/jenkins.sh index bd7bcc00b1..2d69faf60c 100755 --- a/jenkins.sh +++ b/jenkins.sh @@ -2,6 +2,11 @@ : "${JENKINS_WAR:="/usr/share/jenkins/jenkins.war"}" : "${JENKINS_HOME:="/var/jenkins_home"}" + +if [[ -n "${PRE_CLEAR_INIT_GROOVY_D}" ]]; then + rm -rf "${JENKINS_HOME}/init.groovy.d" +fi + : "${COPY_REFERENCE_FILE_LOG:="${JENKINS_HOME}/copy_reference_file.log"}" : "${REF:="/usr/share/jenkins/ref"}" touch "${COPY_REFERENCE_FILE_LOG}" || { echo "Can not write to ${COPY_REFERENCE_FILE_LOG}. Wrong volume permissions?"; exit 1; }