在Jenkins Docker镜像中安装插件失败。

7
我有一个Dockerfile,用于创建一个自定义的Jenkins主节点,内容如下:
FROM jenkins/jenkins:lts
USER root
ENV http_proxy http://xx.xx.xx.xx:8080
ENV https_proxy http://xx.xx.xx.xx:8080
RUN apt-get update
RUN apt-get install -y --allow-unauthenticated ldap-utils curl wget vim nano sudo git
RUN adduser jenkins sudo
User jenkins
ENV http_proxy http://xx.xx.xx.xx:8080
ENV https_proxy http://xx.xx.xx.xx:8080
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN  /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
RUN echo 2.176.2 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state
RUN echo 2.176.2 > /usr/share/jenkins/ref/jenkins.install.InstallUtil.lastExecVersion
EXPOSE 9081
EXPOSE 50000

我期望在docker build命令docker build --no-cache -t jenkins .期间安装插件。

但是install-plugins.sh无法安装插件。

-max-time 60 https://updates.jenkins.io/download/plugins/structs-plugin/1.5/structs-plugin.hpi -o /usr/share/jenkins/ref/plugins/structs-plugin.jpi)
Failed to download plugin: structs or structs-plugin
curl: (22) The requested URL returned error: 403 Forbidden
14:21:00 Failure (22) Retrying in 1 seconds...
14:21:01 Failed in the last attempt (curl -sSfL --connect-timeout 20 --retry 3 --retry-delay 0 --retry-max-time 60 https://updates.jenkins.io/download/plugins/github-branch-source/1.10/github-branch-source.hpi -o /usr/share/jenkins/ref/plugins/github-branch-source.jpi)
Downloading plugin: github-branch-source-plugin from https://updates.jenkins.io/download/plugins/github-branch-source-plugin/1.10/github-branch-source-plugin.hpi
14:21:01 Failed in the last attempt (curl -sSfL --connect-timeout 20 --retry 3 --retry-delay 0 --retry-max-time 60 https://updates.jenkins.io/download/plugins/dashboard-view/2.9.10/dashboard-view.hpi -o /usr/share/jenkins/ref/plugins/dashboard-view.jpi)
Downloading plugin: dashboard-view-plugin from https://updates.jenkins.io/download/plugins/dashboard-view-plugin/2.9.10/dashboard-view-plugin.hpi
curl: (22) The requested URL returned error: 403 Forbidden
14:21:01 Failure (22) Retrying in 1 seconds...
14:21:01 Failed in the last attempt (curl -sSfL --connect-timeout 20 --retry 3 --retry-delay 0 --retry-max-time 60 https://updates.jenkins.io/download/plugins/statusmonitor/1.3/statusmonitor.hpi -o /usr/share/jenkins/ref/plugins/statusmonitor.jpi)
Downloading plugin: statusmonitor-plugin from https://updates.jenkins.io/download/plugins/statusmonitor-plugin/1.3/statusmonitor-plugin.hpi
14:21:01 Failed in the last attempt (curl -sSfL --connect-timeout 20 --retry 3 --retry-delay 0 --retry-max-time 60 https://updates.jenkins.io/download/plugins/ssh-agent/1.8/ssh-agent.hpi -o /usr/share/jenkins/ref/plugins/ssh-agent.jpi)

你能访问这个地址吗 https://updates.jenkins.io/download/plugins/structs-plugin/1.5/structs-plugin.hpi - Shmuel
插件的 URL 不正确。正确的 URL 是 https://updates.jenkins.io/download/plugins/structs/1.5/structs.hpi,但现在出现了不同的错误:[/usr/share/jenkins/ref/plugins/plugins/copyartifact.jpi] 找不到尾端中央目录签名。这个文件要么不是一个压缩包,要么它是一个多部分归档的一个磁盘。在后一种情况下,中央目录和压缩包注释将在此存档的最后一个磁盘上找到。 - user2439278
在构建 Docker 镜像时,您需要确保可以访问互联网。这意味着请检查代理出站连接是否正常工作。 - maheshs007
请确保您的代理允许连接。 - LinPy
1个回答

3
我使用了您的Dockerfile来构建镜像,没有代理,它可以正常工作。我使用了您输出中编写的一些插件。因此,您的Dockerfile没有问题,这个问题可能是代理引起的。
这很容易评估。尝试在使用/不使用代理的情况下下载插件时构建此/另一个镜像。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接