在jenkins docker映像中安装插件失败

时间:2019-10-29 14:28:05

标签: docker jenkins jenkins-docker

我有一个自定义Jenkins主文件的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)

1 个答案:

答案 0 :(得分:3)

我使用您的Dockerfile来构建映像,没有代理,它运行良好。我用了一些写在您的输出中的插件。因此,您的Dockerfile很好,这个问题可能是代理。

这很容易评估。下载带有/不带代理的插件时,尝试构建此/另一个映像。