Merge branch 'master' into weekly
diff --git a/Dockerfile b/Dockerfile
index 9df04bc..307cb40 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,9 +3,10 @@
RUN apt-get update && apt-get install -y wget git curl zip && rm -rf /var/lib/apt/lists/*
ENV JENKINS_HOME /var/jenkins_home
+ENV JENKINS_SLAVE_AGENT_PORT 50000
# Jenkins is ran with user `jenkins`, uid = 1000
-# If you bind mount a volume from host/vloume from a data container,
+# If you bind mount a volume from host/volume from a data container,
# ensure you use same uid
RUN useradd -d "$JENKINS_HOME" -u 1000 -m -s /bin/bash jenkins
@@ -18,8 +19,11 @@
# or config file with your custom jenkins Docker image.
RUN mkdir -p /usr/share/jenkins/ref/init.groovy.d
+ENV TINI_SHA 066ad710107dc7ee05d3aa6e4974f01dc98f3888
+
# Use tini as subreaper in Docker container to adopt zombie processes
-RUN curl -fL https://github.com/krallin/tini/releases/download/v0.5.0/tini-static -o /bin/tini && chmod +x /bin/tini
+RUN curl -fL https://github.com/krallin/tini/releases/download/v0.5.0/tini-static -o /bin/tini && chmod +x /bin/tini \
+ && echo "$TINI_SHA /bin/tini" | sha1sum -c -
COPY init.groovy /usr/share/jenkins/ref/init.groovy.d/tcp-slave-agent-port.groovy
diff --git a/README.md b/README.md
index 02c0f59..b6aa5f3 100644
--- a/README.md
+++ b/README.md
@@ -99,6 +99,17 @@
EXPOSE 8083
```
+You can also change the default slave agent port for jenkins by defining `JENKINS_SLAVE_AGENT_PORT` in a sample Dockerfile.
+
+```
+FROM jenkins:1.565.3
+ENV JENKINS_SLAVE_AGENT_PORT 50001
+```
+or as a parameter to docker,
+```
+docker run --name myjenkins -p 8080:8080 -p 50001:50001 --env JENKINS_SLAVE_AGENT_PORT=50001 jenkins
+```
+
# 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:
diff --git a/init.groovy b/init.groovy
index 83c3a3d..db8aae2 100644
--- a/init.groovy
+++ b/init.groovy
@@ -5,5 +5,8 @@
Thread.start {
sleep 10000
println "--> setting agent port for jnlp"
- Jenkins.instance.setSlaveAgentPort(50000)
+ def env = System.getenv()
+ int port = env['JENKINS_SLAVE_AGENT_PORT'].toInteger()
+ Jenkins.instance.setSlaveAgentPort(port)
+ println "--> setting agent port for jnlp... done"
}
diff --git a/jenkins.sh b/jenkins.sh
index 7c85291..97d7fcc 100755
--- a/jenkins.sh
+++ b/jenkins.sh
@@ -23,7 +23,7 @@
}
export -f copy_reference_file
echo "--- Copying files at $(date)" >> $COPY_REFERENCE_FILE_LOG
-find /usr/share/jenkins/ref/ -type f -exec bash -c 'copy_reference_file {}' \;
+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
if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; then