使用默认插件设置Docker Jenkins [英] Setup Docker Jenkins with default plugins
问题描述
我想创建一个基于Jenkins的映像,以安装一些插件以及npm
.为此,我具有以下Dockerfile
:
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:
- 由于某些原因,我尝试手动安装的插件似乎并没有持久化.
- 系统提示我要安装的插件列表,但我不想安装其他插件.
我是否缺少配置Dockerfile的所有内容,还是我想实现的目标根本不可能?
Am I missing anything configuring the Dockerfile or is it that what I want to achieve is simply not possible?
推荐答案
在没有看到install-plugins.sh
内容的情况下,我无法评论为什么插件无法持久保存.这很可能是由不正确的安装目标引起的.持久性在这个阶段不应该成为问题,因为插件安装是内置在映像本身中的.
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.
对于后一个问题,您应该可以通过将ENV JAVA_OPTS=-Djenkins.install.runSetupWizard=false
行添加到Dockerfile中来完全跳过安装向导.请注意,如果Jenkins图像暴露在全世界,这可能会带来安全隐患,因为此选项会禁止身份验证
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
Docker映像的默认插件目录为/var/jenkins_home/plugins
The default plugin directory for the Docker image is /var/jenkins_home/plugins
根据Jenkins Docker存储库上的自述文件,添加RUN echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state
行应能完成相同的事情
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
这篇关于使用默认插件设置Docker Jenkins的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!