Escape variables
diff --git a/jenkins.sh b/jenkins.sh
index 97d7fcc..eeed64b 100755
--- a/jenkins.sh
+++ b/jenkins.sh
@@ -7,22 +7,22 @@
# 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%/}
- echo "$f" >> $COPY_REFERENCE_FILE_LOG
- rel=${f:23}
- dir=$(dirname ${f})
- echo " $f -> $rel" >> $COPY_REFERENCE_FILE_LOG
+ f="${1%/}"
+ 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} ]]
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};
+ 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}";
# pin plugins on initial copy
- [[ ${rel} == plugins/*.jpi ]] && touch /var/jenkins_home/${rel}.pinned
+ [[ ${rel} == plugins/*.jpi ]] && touch "/var/jenkins_home/${rel}.pinned"
fi;
}
export -f copy_reference_file
-echo "--- Copying files at $(date)" >> $COPY_REFERENCE_FILE_LOG
+echo "--- Copying files at $(date)" >> "$COPY_REFERENCE_FILE_LOG"
find /usr/share/jenkins/ref/ -type f -exec bash -c "copy_reference_file '{}'" \;
# if `docker run` first argument start with `--` the user is passing jenkins launcher arguments