在Docker插件中构建Jenkins时无法安装

时间:2016-09-30 02:55:56

标签: jenkins docker jenkins-plugins

我有一个自定义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的问题吗?

8 个答案:

答案 0 :(得分:1)

我记得自己安装该脚本时遇到问题。相反,我使用了以下内容:

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

希望它对此没什么影响,但是我的插件安装在我的Dockerfile的根部分内部,然后再回到USER jenkins运行命令。

答案 1 :(得分:1)

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

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,或设置automated build on Docker Hub并在Docker的服务器上构建它。

答案 2 :(得分:1)

对于那些正在从dockerHub中提取jenkins映像的人,请不要提取:

docker pull jenkins

docker pull jenkinsci/jenkins

使用以下方法获取最新版本:

docker pull jenkins/jenkins 

这是根据https://jenkins.io/blog/2018/12/10/the-official-Docker-image/

的最新消息

答案 3 :(得分:1)

Dockerfile

FROM jenkins/jenkins:latest

ENV CURL_OPTIONS -sSfLk
ENV JENKINS_OPTS --httpPort=-1

答案 4 :(得分:0)

下载插件的卷曲超时在某些情况下是不够的,仅针对图片2.19.1进行了修复,现在可以使用CURL_CONNECTION_TIMEOUT和其他选项进行配置

答案 5 :(得分:0)

我在OS X上遇到了同样的问题。

在我的情况下,问题是由错误的DNS配置(由DHCP获得)引起的。当我将DNS更改为Googles DNS 8.8.8.8时,一切都运行良好。

我遇到了错误消息,例如: 无法解析主机名“ftp.icm.edu.pl”。也许您需要配置HTTP代理

答案 6 :(得分:0)

我有一个非常类似的问题,我的解决方案是在插件安装之前在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

答案 7 :(得分:-3)

这可能是DNS问题。请重新启动docker daemon并尝试。 (sudo服务docker restart)