docker - 在 jenkins docker 映像中安装插件失败
问题描述
我有一个自定义 Jenkins master 的 Dockerfile,如下所示:
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)
解决方案
我使用你的 Dockerfile 来构建图像,没有代理,它工作正常。我使用了一些在您的输出中编写的插件。所以,你的 Dockerfile 很好,这个问题可能是代理。
这可以很容易地评估。在下载带/不带代理的插件时尝试构建这个/另一个图像。
推荐阅读
- python - Tensorflow 在 PyCharm 中不起作用 - DLL 加载失败:找不到特定模块
- javascript - 视差鼠标如何移动效果纯javascript
- python - JSONField 嵌套表示的序列化器
- plsql - 在 PL/SQL 中不使用 TO_CHAR 将整数连接到字符串
- c# - 如何将 xamarin 标签隐藏到属性或其他内容
- bash - Bash 脚本未在 .lua 上执行,退出状态 7(参数列表太长)
- javascript - 无法以角度过滤日期
- azure - 横向扩展 azure 应用服务与容器
- python - python中的分层采样,有约束
- javascript - 使用 vanilla Javascript 从选定的单选按钮中选择下一个/上一个单选按钮