11

I have a Dockerfile for a custom Jenkins master like so:

FROM jenkins
MAINTAINER me

USER root

RUN echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state

RUN apt-get update \
      && apt-get install -y sudo \
      && apt-get install -y vim \
      && rm -rf /var/lib/apt/lists/*
RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers

USER jenkins

# COPY plugins.txt /usr/share/jenkins/plugins.txt
# RUN /usr/local/bin/plugins.sh /usr/share/jenkins/plugins.txt
ENV JAVA_OPTS="-Xmx8192m"
ENV JENKINS_OPTS="--handlerCountStartup=100 --handlerCountMax=300"


RUN /usr/local/bin/install-plugins.sh git:2.6.0

Everything works fine until the RUN /usr/local/bin/install-plugins.sh git:2.6.0 line. I get an error installing the plugins:

Creating initial locks...

Analyzing war...

Downloading plugins...
Downloading plugin: git from https://updates.jenkins.io/download/plugins/git/2.6.0/git.hpi
Downloading plugin: git-plugin from https://updates.jenkins.io/download/plugins/git-plugin/2.6.0/git-plugin.hpi
Failed to download plugin: git or git-plugin

WAR bundled plugins:


Installed plugins:
*:

Some plugins failed to download!
Not downloaded: git
The command '/bin/sh -c /usr/local/bin/install-plugins.sh git:2.6.0' returned a non-zero code: 1

Am I doing something wrong or is this an issue with Jenkins/Docker?

rainkinz
  • 10,082
  • 5
  • 45
  • 73

8 Answers8

24

For those who are pulling the jenkins image from dockerHub, dont pull:

docker pull jenkins

or

docker pull jenkinsci/jenkins

rather pull the latest version using:

docker pull jenkins/jenkins 

This is the latest one according to https://jenkins.io/blog/2018/12/10/the-official-Docker-image/

EpicJoker
  • 349
  • 2
  • 15
Manish Sakariya
  • 482
  • 3
  • 10
  • 1
    As of 04282020 ```docker pull jenkins``` never works as this has been deprecated. I will docker official website would remove this command to save a day for a developer like me. – Ariful Haque Apr 28 '20 at 14:52
  • Thx, your tip to use the latest jenkins version for docker helped me. – Honsa Stunna Aug 26 '20 at 12:48
2

Your Dockerfile works for me, installs all plugins and builds the image successfully:

Analyzing war... 
Downloading plugins...
Downloading plugin: git from https://updates.jenkins.io/download/plugins/git/2.6.0/git.hpi
 > git depends on workflow-scm-step:1.14.2,mailer:1.17,matrix-project:1.7.1,ssh-credentials:1.12,parameterized-trigger:2.4;resolution:=optional,scm-api:1.2,token-macro:1.11;resolution:=optional,promoted-builds:2.27;resolution:=optional,credentials:2.1.4,git-client:1.21.0

Downloading plugin: workflow-scm-step from https://updates.jenkins.io/download/plugins/workflow-scm-step/latest/workflow-scm-step.hpi
...
Removing intermediate container 4f895c203944
Successfully built 31d58d1f586f  

Try docker build --no-cache in case there's an issue with one of the layers in your image cache, or set up an automated build on Docker Hub and build it on Docker's servers.

Elton Stoneman
  • 17,906
  • 5
  • 47
  • 44
  • Well it worked on Docker Hub, thanks. I wouldn't have thought of trying this. Must be something with my local environment. I'm using docker for mac. – rainkinz Sep 30 '16 at 11:40
1

I recall having problems installing with that script myself. Instead, I used the following:

RUN install-plugins.sh  \
  disable-failed-job \
  disk-usage \
  greenballs \
  ...

And hopefully it doesn't make a difference for this, but I have my plugin install inside of the root portion of my Dockerfile, before dropping back to running commands as USER jenkins.

BMitch
  • 231,797
  • 42
  • 475
  • 450
0

The curl timeouts for downloading plugins were insufficient in some cases, that was just fixed for image 2.19.1, and it is now configurable too using CURL_CONNECTION_TIMEOUT and other options

csanchez
  • 1,623
  • 11
  • 20
0

I had the same problem on OS X.

In my case the problem was caused by a bad DNS configuration (obtained by DHCP). When I changed the DNS to Googles DNS 8.8.8.8 it all worked perfectly.

I encountered error messages such as: Failed to resolve host name "ftp.icm.edu.pl". Perhaps you need to configure HTTP proxy

0

I had a very similar issue and the solution for me was to specify the proxy within the Docker file prior to plugin install. Below is the snippet of my Dockerfile

FROM jenkins:latest
MAINTAINER Jose Estrada
USER root
ENV JAVA_OPTS="--handlerCountStartup=100 --handlerCountMax=300 --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war -Dhttps.proxyHost=proxy-wsa.esl.cisco.com -Dhttps.proxyPort=80"
ENV http_proxy <PROXY Settings>
ENV https_proxy <PROXY Settings>
RUN /usr/local/bin/install-plugins.sh cisco-spark-notifier:latest
0

Dockerfile

FROM jenkins/jenkins:latest

ENV CURL_OPTIONS -sSfLk
ENV JENKINS_OPTS --httpPort=-1
viniciusalvess
  • 756
  • 8
  • 18
  • 2
    Would have been nice if you shared some context to your answer. Adding `ENV JENKINS_OPTS --httpPort=-1` Makes the web interface completely unusable. Maybe you had a reason to include this option but without context adding that line broke the web interface. – Dave Nov 19 '21 at 13:26
-3

This could be a DNS issue. Please restart docker daemon and try. (sudo service docker restart)