简体   繁体   中英

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:

  • It seems that the plugins I tried to install manually didn't get persisted for some reason.
  • I get prompted the list of plugins I want to install but I don't want to install anything else.

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

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.state should accomplish the same thing

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM