Installing Jenkins Plugins to Docker Jenkins

2020-02-09 02:22发布

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 enter image description here

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

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

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

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

1条回答
霸刀☆藐视天下
2楼-- · 2020-02-09 02:34

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:

  • 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.

查看更多
登录 后发表回答