在Docker插件中构buildJenkins时无法安装

我有一个自定义Jenkins主的Dockerfile像这样:

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 

一切正常,直到RUN /usr/local/bin/install-plugins.sh git:2.6.0行。 我在安装插件时遇到错误:

 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 

我做错了什么,或者这是Jenkins / Docker的问题?

您的Dockerfile适用于我,安装所有插件并成功构build映像:

 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 

尝试docker build --no-cache ,以防图像caching中的某个层出现问题,或者在Docker Hub上设置自动构build并在Docker服务器上构build它。

我记得有自己的安装与脚本的问题。 相反,我使用了以下内容:

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

并希望它不会有所作为,但我有我的插件安装在我的Dockerfile的根部分之前,作为USER jenkins退回到运行命令。

下载插件的curl超时在某些情况下是不够的,这只是固定的图像CURL_CONNECTION_TIMEOUT ,现在也可以使用CURL_CONNECTION_TIMEOUT和其他选项

我在OS X上有同样的问题。

在我的情况下,这个问题是由一个错误的DNSconfiguration(由DHCP获得)造成的。 当我将DNS更改为Google的DNS 8.8.8.8时,它一切正常。

我遇到了如下错误消息:无法parsing主机名“ftp.icm.edu.pl”。 也许你需要configurationHTTP代理

我有一个非常类似的问题,我的解决scheme是在插件安装之前在Docker文件中指定代理。 以下是我的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