将 Jenkins 插件安装到 Docker Jenkins [英] Installing Jenkins Plugins to Docker Jenkins

查看:48
本文介绍了将 Jenkins 插件安装到 Docker Jenkins的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 Dockerfile,以 jenkins 作为基础镜像:

I have the following Dockerfile with jenkins as the base image:

FROM jenkins
USER root
ENV JENKINS_MIRROR http://mirrors.jenkins-ci.org
RUN for plugin in git-client git ws-cleanup ; do wget -O $JENKINS_HOME/plugins/${plugin}.hpi $JENKINS_MIRROR/plugins/${plugin}/latest/${plugin}.hpi ; done
EXPOSE 8080

我正在尝试安装一些额外的插件,但它给了我一个错误,说没有这样的文件或目录

I'm trying to install some additional plugins but it gives me an error saying no such file or directory

然后我启动并连接到此构建步骤的容器以调试"错误:

I then started and connected to the container of this build step in order to "debug" the error:

但是,我找不到原因,因为每个目录似乎都存在.此外,如果我然后在 bash 中手动运行 for 循环,则所有插件都已正确安装...

However, I could not find out the cause because every directory seems to exist. Furthermore, if I then run the for-loop manually in the bash, all plugins are installed correctly...

我进一步注意到,如果我将它们安装在根目录中,插件的安装是有效的:

I further noticed, that the installation of the the plugins works, if I install them in the root directory as follows:

RUN for plugin in git-client git ws-cleanup ; do wget -O ${plugin}.hpi $JENKINS_MIRROR/plugins/${plugin}/latest/${plugin}.hpi ; done

然而,这是错误的地方,因为它们必须放在 $JENKINS_HOME/plugins 目录中

However, this is the wrong place as they have to be placed in the directory $JENKINS_HOME/plugins

为什么我无法在 $JENKINS_HOME/plugins 中安装插件?

Why I am not able to install the plugins in $JENKINS_HOME/plugins?

推荐答案

我无法阅读您的屏幕截图,但您似乎没有按照官方说明进行操作.见 https://github.com/cloudbees/jenkins-ci.org-docker 在安装更多工具"下.注意:

I can't read your screenshots, but you don't seem to be following the official instructions. See https://github.com/cloudbees/jenkins-ci.org-docker under "Installing more tools". Note:

  • 您应该将插件保存到 /usr/share/jenkins/ref/plugins
  • 您可以改用 plugins.txt 文件,其中包含插件的名称,并且您可以使用提供的 plugins.sh 脚本进行处理.这看起来像:
  • You should save the plugins to /usr/share/jenkins/ref/plugins
  • You could use a plugins.txt file instead, which contains the names of your plug-ins, and you can process with the provided plugins.sh script. This looks like:
COPY plugins.txt /usr/share/jenkins/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/plugins.txt

我认为您的方法不起作用的原因是启动脚本中的一些处理.

I think the reason your approach wasn't working was to do with some processing in the start-up script.

这篇关于将 Jenkins 插件安装到 Docker Jenkins的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆