簡體   English   中英

在 Docker 插件中構建 Jenkins 時安裝失敗

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

我有一個自定義 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 有問題?

對於那些從 dockerHub 拉取 jenkins 鏡像的人,不要拉:

docker pull jenkins

docker pull jenkinsci/jenkins

而是使用以下方法拉取最新版本:

docker pull jenkins/jenkins

這是最新的https://jenkins.io/blog/2018/12/10/the-official-Docker-image/

您的 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以防圖像緩存中的某一層出現問題,或者在 Docker Hub 上設置自動構建並在 Docker 的服務器上構建它。

我記得自己在安裝該腳本時遇到了問題。 相反,我使用了以下內容:

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

希望它不會對此產生影響,但是我在 Dockerfile 的根部分內安裝了我的插件,然后再回到以USER jenkins身份運行命令。

文件

FROM jenkins/jenkins:latest

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

下載插件卷曲超時是在某些情況下,這只是固定的圖像不足2.19.1 ,並且它也使用現在配置CURL_CONNECTION_TIMEOUT和其他選項

我在 OS X 上遇到了同樣的問題。

在我的情況下,問題是由錯誤的 DNS 配置(由 DHCP 獲得)引起的。 當我將 DNS 更改為 Googles DNS 8.8.8.8 時,一切正常。

我遇到了錯誤消息,例如:無法解析主機名“ftp.icm.edu.pl”。 也許你需要配置HTTP代理

我有一個非常相似的問題,我的解決方案是在插件安裝之前在 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

這可能是 DNS 問題。 請重新啟動 docker 守護進程並嘗試。 (sudo 服務 docker 重啟)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM