Thanks @MarkEWaite ! Specifying the full plugins.txt with pinned versions of dependencies indeed does the trick. I’m now able to build and run with the existing (old) plugins installed.
So, now we are faced with upgrading to jenkins/jenkins:2.452.3-lts-jdk17
.
What is not entirely clear to me from the Jenkins docs is, what is the recommended upgrade procedure for upgrading plugins, as part of a large Jenkins/JDK version upgrade such as this one?
Should we remove the existing plugins/
directory from the currently-used jenkins_home
volume prior to upgrade?
To reproduce this situation - create Dockerfile.old
:
# Dockerfile.old
FROM jenkins/jenkins:2.346.3-lts-jdk8
# plugins.old.txt contains dump of full plugin:version
# export from Jenkins Script Console
COPY plugins.old.txt /tmp
RUN set -eux \
&& jenkins-plugin-cli \
--verbose \
--plugin-file /tmp/plugins.old.txt \
&& mkdir -pv ${JENKINS_HOME}/plugins \
&& cp -r -p \
/usr/share/jenkins/ref/plugins/. \
${JENKINS_HOME}/plugins/.
Build and run as:
docker build -f Dockerfile.old -t old-jenkins .
docker volume create jenkins_home
docker run -d -p 8080:8080 -p 50000:50000 \
-v jenkins_home:/var/jenkins_home \
--name jenkins \
old-jenkins
This will provide a Jenkins 2.346.3 controller running on JDK 8 with the working (old) plugins installed.
Now we are faced with running a new container based on jenkins/jenkins:2.452.3-jdk17
that uses a mount for the existing jenkins_home
volume.
For instance,
docker container stop jenkins
docker container rm jenkins
Now, cp plugins.old.txt plugins.new.txt
, and remove the pinned :version
specifiers from plugins.new.txt
to allow the versions to float to the latest.
Then create create Dockerfile.new
:
# Dockerfile.new
FROM jenkins/jenkins:2.452.3-lts-jdk17
COPY plugins.new.txt /tmp
RUN set -eux \
&& jenkins-plugin-cli \
--verbose \
--plugin-file /tmp/plugins.new.txt \
&& mkdir -pv ${JENKINS_HOME}/plugins \
&& cp -r -p \
/usr/share/jenkins/ref/plugins/. \
${JENKINS_HOME}/plugins/.
Build and run as:
docker build -f Dockerfile.new -t new-jenkins .
docker run -d -p 8080:8080 -p 50000:50000 \
-v jenkins_home:/var/jenkins_home \
--name jenkins \
new-jenkins
Then, docker logs jenkins
will show many errors such as the following:
Failed Loading plugin Mina SSHD API :: Core v2.12.1-101.v85b_e08b_780dd (mina-sshd-api-core)
Update required: SSH Credentials Plugin (ssh-credentials 305.v8f4381501156) to be updated to 326.v7fcb_a_ef6194b_ or higher
These errors make sense since the plugins/
directory from jenkins_home
Docker volume eclipses the plugins/
that are copied to ${JENKINS_HOME}/plugins/
as part of the declarative Docker image build process. In other words, the plugins that we attempt to pre-install into the new image are overridden by the existing old plugins – and the old plugins raise errors since they are incompatible with the new Jenkins version.