Merge branch 'master' into weekly
diff --git a/Dockerfile b/Dockerfile
index 68f0d7f..2b1fc9f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM java:openjdk-7u65-jdk
+FROM java:8u45-jdk
RUN apt-get update && apt-get install -y wget git curl zip && rm -rf /var/lib/apt/lists/*
@@ -19,15 +19,18 @@
RUN mkdir -p /usr/share/jenkins/ref/init.groovy.d
-COPY init.groovy /usr/share/jenkins/ref/init.groovy.d/tcp-slave-angent-port.groovy
+COPY init.groovy /usr/share/jenkins/ref/init.groovy.d/tcp-slave-agent-port.groovy
-ENV JENKINS_VERSION 1.605
+ENV JENKINS_VERSION 1.609.1
+ENV JENKINS_SHA 698284ad950bd663c783e99bc8045ca1c9f92159
# could use ADD but this one does not check Last-Modified header
# see https://github.com/docker/docker/issues/8331
-RUN curl -L http://mirrors.jenkins-ci.org/war/1.605/jenkins.war -o /usr/share/jenkins/jenkins.war
+RUN curl -fL http://mirrors.jenkins-ci.org/war/$JENKINS_VERSION/jenkins.war -o /usr/share/jenkins/jenkins.war \
+ && echo "$JENKINS_SHA /usr/share/jenkins/jenkins.war" | sha1sum -c -
ENV JENKINS_UC https://updates.jenkins-ci.org
+ENV JENKINS_UC_DOWNLOAD $JENKINS_UC/download
RUN chown -R jenkins "$JENKINS_HOME" /usr/share/jenkins/ref
# for main web interface:
@@ -36,6 +39,9 @@
# will be used by attached slave agents:
EXPOSE 50000
+ENV COPY_REFERENCE_FILE_LOG /var/log/copy_reference_file.log
+RUN touch $COPY_REFERENCE_FILE_LOG && chown jenkins.jenkins $COPY_REFERENCE_FILE_LOG
+
USER jenkins
COPY jenkins.sh /usr/local/bin/jenkins.sh
diff --git a/README.md b/README.md
index 9d9a956..eed7542 100644
--- a/README.md
+++ b/README.md
@@ -46,7 +46,7 @@
# Attaching build executors
-You can run builds on the master (out of the box) buf if you want to attach build slave servers: make sure you map the port: ```-p 50000:50000``` - which will be used when you connect a slave agent.
+You can run builds on the master (out of the box) but if you want to attach build slave servers: make sure you map the port: ```-p 50000:50000``` - which will be used when you connect a slave agent.
<a href="https://registry.hub.docker.com/u/maestrodev/build-agent/">Here</a> is an example docker container you can use as a build server with lots of good tools installed - which is well worth trying.
@@ -88,7 +88,7 @@
FROM jenkins
# if we want to install via apt
USER root
-RUN apt-get install -y ruby make more-thing-here
+RUN apt-get update && apt-get install -y ruby make more-thing-here
USER jenkins # drop back to the regular jenkins user - good practice
```
@@ -98,8 +98,9 @@
```
FROM jenkins
-COPY plugins /usr/share/jenkins/ref/plugins
+COPY plugins.txt /usr/share/jenkins/ref/
COPY custom.groovy /usr/share/jenkins/ref/init.groovy.d/custom.groovy
+RUN /usr/local/bin/plugins.sh /usr/share/jenkins/ref/plugins.txt
```
When jenkins container starts, it will check JENKINS_HOME has this reference content, and copy them 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.
diff --git a/jenkins.sh b/jenkins.sh
index 1bd0f85..7c85291 100755
--- a/jenkins.sh
+++ b/jenkins.sh
@@ -1,23 +1,28 @@
#! /bin/bash
+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
# can then change this, upgrade plugins, etc.
copy_reference_file() {
f=${1%/}
- echo "$f"
+ echo "$f" >> $COPY_REFERENCE_FILE_LOG
rel=${f:23}
dir=$(dirname ${f})
- echo " $f -> $rel"
+ echo " $f -> $rel" >> $COPY_REFERENCE_FILE_LOG
if [[ ! -e /var/jenkins_home/${rel} ]]
then
- echo "copy $rel to JENKINS_HOME"
+ 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 /usr/share/jenkins/ref/${rel} /var/jenkins_home/${rel};
+ # pin plugins on initial copy
+ [[ ${rel} == plugins/*.jpi ]] && touch /var/jenkins_home/${rel}.pinned
fi;
}
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 {}' \;
# if `docker run` first argument start with `--` the user is passing jenkins launcher arguments
diff --git a/plugins.sh b/plugins.sh
index df060b3..f597a12 100755
--- a/plugins.sh
+++ b/plugins.sh
@@ -2,18 +2,22 @@
# Parse a support-core plugin -style txt file as specification for jenkins plugins to be installed
# in the reference directory, so user can define a derived Docker image with just :
-#
+#
# FROM jenkins
# COPY plugins.txt /plugins.txt
# RUN /usr/local/bin/plugins.sh /plugins.txt
-#
+#
+
+set -e
REF=/usr/share/jenkins/ref/plugins
mkdir -p $REF
-while read spec; do
- plugin=(${spec//:/ });
+while read spec || [ -n "$spec" ]; do
+ plugin=(${spec//:/ });
[[ ${plugin[0]} =~ ^# ]] && continue
[[ ${plugin[0]} =~ ^\s*$ ]] && continue
- curl -L ${JENKINS_UC}/download/plugins/${plugin[0]}/${plugin[1]}/${plugin[0]}.hpi -o $REF/${plugin[0]}.hpi;
+ [[ -z ${plugin[1]} ]] && plugin[1]="latest"
+ echo "Downloading ${plugin[0]}:${plugin[1]}"
+ curl -s -L -f ${JENKINS_UC_DOWNLOAD}/plugins/${plugin[0]}/${plugin[1]}/${plugin[0]}.hpi -o $REF/${plugin[0]}.jpi
done < $1