Merge pull request #186 from bastiaanb/feature/config-files-can-override-2
if a config file has .override appended to its name, it will overrideā¦
diff --git a/README.md b/README.md
index f8f14e5..4b34861 100644
--- a/README.md
+++ b/README.md
@@ -76,7 +76,7 @@
# Passing JVM parameters
-You might need to customize the JVM running Jenkins, typically to pass system properties or tweak heap memory settings. Use JAVA_OPTS environment
+You might need to customize the JVM running Jenkins, typically to pass system properties or tweak heap memory settings. Use JAVA_OPTS environment
variable for this purpose :
```
@@ -133,7 +133,7 @@
# Installing more tools
-You can run your container as root - and install via apt-get, install as part of build steps via jenkins tool installers, or you can create your own Dockerfile to customise, for example:
+You can run your container as root - and install via apt-get, install as part of build steps via jenkins tool installers, or you can create your own Dockerfile to customise, for example:
```
FROM jenkins
@@ -143,7 +143,7 @@
USER jenkins # drop back to the regular jenkins user - good practice
```
-In such a derived image, you can customize your jenkins instance with hook scripts or additional plugins.
+In such a derived image, you can customize your jenkins instance with hook scripts or additional plugins.
For this purpose, use `/usr/share/jenkins/ref` as a place to define the default JENKINS_HOME content you
wish the target installation to look like :
@@ -158,6 +158,9 @@
there if required. It will not override such files, so if you upgraded some plugins from UI they won't
be reverted on next start.
+In case you *do* want to override, append '.override' to the name of the reference file. E.g. a file named
+`/usr/share/jenkins/ref/config.xml.override` will overwrite an existing `config.xml` file in JENKINS_HOME.
+
Also see [JENKINS-24986](https://issues.jenkins-ci.org/browse/JENKINS-24986)
For your convenience, you also can use a plain text file to define plugins to be installed
diff --git a/jenkins.sh b/jenkins.sh
index 86e1c57..718572c 100755
--- a/jenkins.sh
+++ b/jenkins.sh
@@ -3,23 +3,24 @@
set -e
# Copy files from /usr/share/jenkins/ref into /var/jenkins_home
-# So the initial JENKINS-HOME is set with expected content.
-# Don't override, as this is just a reference setup, and use from UI
+# So the initial JENKINS-HOME is set with expected content.
+# Don't override, as this is just a reference setup, and use from UI
# can then change this, upgrade plugins, etc.
copy_reference_file() {
f="${1%/}"
+ b="${f%.override}"
echo "$f" >> "$COPY_REFERENCE_FILE_LOG"
- rel="${f:23}"
- dir=$(dirname "${f}")
- echo " $f -> $rel" >> "$COPY_REFERENCE_FILE_LOG"
- if [[ ! -e /var/jenkins_home/${rel} ]]
+ rel="${b:23}"
+ dir=$(dirname "${b}")
+ echo " $f -> $rel" >> "$COPY_REFERENCE_FILE_LOG"
+ if [[ ! -e /var/jenkins_home/${rel} || $f = *.override ]]
then
echo "copy $rel to JENKINS_HOME" >> "$COPY_REFERENCE_FILE_LOG"
mkdir -p "/var/jenkins_home/${dir:23}"
- cp -r "/usr/share/jenkins/ref/${rel}" "/var/jenkins_home/${rel}";
+ cp -r "${f}" "/var/jenkins_home/${rel}";
# pin plugins on initial copy
[[ ${rel} == plugins/*.jpi ]] && touch "/var/jenkins_home/${rel}.pinned"
- fi;
+ fi;
}
export -f copy_reference_file
touch "${COPY_REFERENCE_FILE_LOG}" || echo "Can not write to ${COPY_REFERENCE_FILE_LOG}. Wrong volume permissions?"
@@ -33,4 +34,3 @@
# As argument is not jenkins, assume user want to run his own process, for sample a `bash` shell to explore this image
exec "$@"
-