Carlos Torrecillas
Carlos Torrecillas

Reputation: 5736

Setup Docker Jenkins with default plugins

I want to create a Jenkins based image to have some plugins installed as well as npm. To do so I have the following Dockerfile:

FROM jenkins:2.60.3
RUN install-plugins.sh bitbucket
USER root
RUN apt-get update
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get install -y nodejs
RUN npm --version
USER jenkins

That works fine however when I run the image I have two problems:

Am I missing anything configuring the Dockerfile or is it that what I want to achieve is simply not possible?

Upvotes: 1

Views: 3035

Answers (2)

Alexey Novgorodov
Alexey Novgorodov

Reputation: 411

Things have changed since 2017, when the last answer was posted, and it no longer works. The current way is in following Dockerfile snippet:

# Prevent setup wizard from running.
# WARNING: Jenkins will start with security disabled, without any password.

ENV JENKINS_OPTS="-Djenkins.install.runSetupWizard=false"

# plugins.txt must contain the list of plugins to be installed
# (One plugin per line, e.g. sidebar-link:1.11.0)

COPY plugins.txt /tmp/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /tmp/plugins.txt

Upvotes: 0

cstarner
cstarner

Reputation: 387

Without seeing the contents of install-plugins.sh, I can't comment as to why the plugins aren't persisting. It is most likely caused by an incorrect installation destination; persistence shouldn't be an issue at this stage, since the plugin installation is built into the image itself.

As for the latter issue, you should be able to skip the installation wizard altogether by adding the line ENV JAVA_OPTS=-Djenkins.install.runSetupWizard=false to your Dockerfile. Please note that this can be a security risk, if the Jenkins image is exposed to the world at large, since this option disables the need for authentication

EDIT: The default plugin directory for the Docker image is /var/jenkins_home/plugins

EDIT 2: According to the README on the Jenkins Docker repo, adding the line RUN echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.stateshould accomplish the same thing

Upvotes: 3

Related Questions