简体   繁体   English

在 Docker 插件中构建 Jenkins 时安装失败

[英]When building Jenkins in Docker plugins fail to install

I have a Dockerfile for a custom Jenkins master like so:我有一个自定义 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

Everything works fine until the RUN /usr/local/bin/install-plugins.sh git:2.6.0 line.一切正常,直到RUN /usr/local/bin/install-plugins.sh git:2.6.0行。 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?我做错了什么还是 Jenkins/Docker 有问题?

For those who are pulling the jenkins image from dockerHub, dont pull:对于那些从 dockerHub 拉取 jenkins 镜像的人,不要拉:

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/这是最新的https://jenkins.io/blog/2018/12/10/the-official-Docker-image/

Your Dockerfile works for me, installs all plugins and builds the image successfully:您的 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  

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.尝试docker build --no-cache以防图像缓存中的某一层出现问题,或者在 Docker Hub 上设置自动构建并在 Docker 的服务器上构建它。

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 .希望它不会对此产生影响,但是我在 Dockerfile 的根部分内安装了我的插件,然后再回到以USER jenkins身份运行命令。

Dockerfile文件

FROM jenkins/jenkins:latest

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

下载插件卷曲超时是在某些情况下,这只是固定的图像不足2.19.1 ,并且它也使用现在配置CURL_CONNECTION_TIMEOUT和其他选项

I had the same problem on OS X.我在 OS X 上遇到了同样的问题。

In my case the problem was caused by a bad DNS configuration (obtained by DHCP).在我的情况下,问题是由错误的 DNS 配置(由 DHCP 获得)引起的。 When I changed the DNS to Googles DNS 8.8.8.8 it all worked perfectly.当我将 DNS 更改为 Googles DNS 8.8.8.8 时,一切正常。

I encountered error messages such as: Failed to resolve host name "ftp.icm.edu.pl".我遇到了错误消息,例如:无法解析主机名“ftp.icm.edu.pl”。 Perhaps you need to configure HTTP proxy也许你需要配置HTTP代理

I had a very similar issue and the solution for me was to specify the proxy within the Docker file prior to plugin install.我有一个非常相似的问题,我的解决方案是在插件安装之前在 Docker 文件中指定代理。 Below is the snippet of my Dockerfile下面是我的 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

This could be a DNS issue.这可能是 DNS 问题。 Please restart docker daemon and try.请重新启动 docker 守护进程并尝试。 (sudo service docker restart) (sudo 服务 docker 重启)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM