Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Jenkins Plugins to Docker 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 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?

like image 387
René Winkler Avatar asked Mar 29 '15 10:03

René Winkler


People also ask

Is there a Docker plugin for Jenkins?

Jenkins Configuration Docker plugin is a "Cloud" implementation. You'll need to edit Jenkins system configuration (Jenkins -> Manage -> System configuration) and add a new Cloud of type "Docker". Configure Docker (or Swarm standalone) API URL with required credentials. The test button lets you check the connection.

Should I use Jenkins in Docker?

The main reason is that Jenkins pipelines work really well with Docker. Without Docker you need to install additional tools and add different agents to Jenkins. With Docker, there is no need to install additional tools, you just use images of these tools.


1 Answers

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.

like image 188
Adrian Mouat Avatar answered Oct 21 '22 14:10

Adrian Mouat