我正在使用以下Dockerfile来构建具有预安装插件的Jenkins镜像。

FROM jenkins

USER root
RUN apt-get -yqq update
RUN curl -sSL https://get.docker.com/ | sh
RUN usermod -aG docker jenkins

COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh $(cat /usr/share/jenkins/ref/plugins.txt)

USER jenkins


但是,遇到有关现有plugin.lock问题的错误。

Step 10/11 : RUN /usr/local/bin/install-plugins.sh $(cat /usr/share/jenkins/ref/plugins.txt)
 ---> Running in 0823515c2574
Creating initial locks...
[91mmkdir: cannot create directory ‘/usr/share/jenkins/ref/plugins/Plugin.lock’: File exists
[0mThe command '/bin/sh -c /usr/local/bin/install-plugins.sh $(cat /usr/share/jenkins/ref/plugins.txt)' returned a non-zero code: 1
Build step 'Execute shell' marked build as failure


我在docker build中使用了“--no-cache”选项,但是没有用。
这是我使用的docker build命令:

docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --no-cache -t ci/jenkins .


有人遇到过这个问题吗?

更新:这是我的plugins.txt

bouncycastle API Plugin (bouncycastle-api): 2.16.1
Pipeline: Groovy (workflow-cps): 2.33
Folders Plugin (cloudbees-folder): 6.0.4
Structs Plugin (structs): 1.7
Branch API Plugin (branch-api): 2.0.9
JUnit Plugin (junit): 1.20
OWASP Markup Formatter Plugin (antisamy-markup-formatter): 1.5
Docker Commons Plugin (docker-commons): 1.6
PAM Authentication plugin (pam-auth): 1.3
Windows Slaves Plugin (windows-slaves): 1.3.1
Pipeline: Stage View Plugin (pipeline-stage-view): 2.8
Display URL API (display-url-api): 2.0
Mailer Plugin (mailer): 1.20
LDAP Plugin (ldap): 1.15
Docker Pipeline (docker-workflow): 1.11
Token Macro Plugin (token-macro): 2.1
External Monitor Job Type Plugin (external-monitor-job): 1.7
Icon Shim Plugin (icon-shim): 2.0.3
Matrix Authorization Strategy Plugin (matrix-auth): 1.6
Pipeline: Build Step (pipeline-build-step): 2.5
Script Security Plugin (script-security): 1.27
Matrix Project Plugin (matrix-project): 1.11
Pipeline: Model API (pipeline-model-api): 1.1.4
build timeout plugin (build-timeout): 1.18
Credentials Plugin (credentials): 2.1.13
Pipeline: Step API (workflow-step-api): 2.10
Plain Credentials Plugin (plain-credentials): 1.4
SSH Credentials Plugin (ssh-credentials): 1.13
Credentials Binding Plugin (credentials-binding): 1.11
Timestamper (timestamper): 1.8.8
SCM API Plugin (scm-api): 2.1.1
Jackson 2 API Plugin (jackson2-api): 2.7.3
Pipeline: API (workflow-api): 2.16
Pipeline: Supporting APIs (workflow-support): 2.14
Durable Task Plugin (durable-task): 1.13
Pipeline: Nodes and Processes (workflow-durable-task-step): 2.11
Git client plugin (git-client): 2.4.6
Resource Disposer Plugin (resource-disposer): 0.6
GitHub API Plugin (github-api): 1.85.1
Workspace Cleanup Plugin (ws-cleanup): 0.33
Ant Plugin (ant): 1.5
Gradle Plugin (gradle): 1.26
Pipeline: SCM Step (workflow-scm-step): 2.4
Pipeline: Milestone Step (pipeline-milestone-step): 1.3.1
JavaScript GUI Lib: jQuery bundles (jQuery and jQuery UI) plugin (jquery-detached): 1.2.1
GIT server Plugin (git-server): 1.7
Pipeline: Input Step (pipeline-input-step): 2.7
Git plugin (git): 3.3.0
JavaScript GUI Lib: ACE Editor bundle plugin (ace-editor): 1.1
Pipeline: Shared Groovy Libraries (workflow-cps-global-lib): 2.8
Pipeline: Stage Step (pipeline-stage-step): 2.2
Pipeline: Job (workflow-job): 2.11
Pipeline Graph Analysis Plugin (pipeline-graph-analysis): 1.3
Pipeline: REST API Plugin (pipeline-rest-api): 2.8
GitHub plugin (github): 1.27.0
JavaScript GUI Lib: Handlebars bundle plugin (handlebars): 1.1.1
JavaScript GUI Lib: Moment.js bundle plugin (momentjs): 1.1.1
Pipeline: Declarative Extension Points API (pipeline-model-extensions): 1.1.4
Pipeline: Multibranch (workflow-multibranch): 2.15
Authentication Tokens API Plugin (authentication-tokens): 1.3
Pipeline: Stage Tags Metadata (pipeline-stage-tags-metadata): 1.1.4
Pipeline: Declarative Agent API (pipeline-model-declarative-agent): 1.1.1
Pipeline: Basic Steps (workflow-basic-steps): 2.5
Pipeline: Model Definition (pipeline-model-definition): 1.1.4
Pipeline (workflow-aggregator): 2.5
GitHub Branch Source Plugin (github-branch-source): 2.0.6
Pipeline: GitHub Groovy Libraries (pipeline-github-lib): 1.0
GitHub Organization Folder Plugin (github-organization-folder): 1.6
MapDB API Plugin (mapdb-api): 1.0.9.0
Subversion Plug-in (subversion): 2.7.2
SSH Slaves plugin (ssh-slaves): 1.17
Email Extension Plugin (email-ext): 2.57.2
Docker Slaves Plugin (docker-slaves): 1.0.6
Docker plugin (docker-plugin): 0.16.1

最佳答案

您需要像这样的文本文件

bouncycastle-api:2.16.1
workflow-cps:2.33

按照
RUN /usr/local/bin/install-plugins.sh \
   docker-slaves \
   github-branch-source:1.8

here进行了调整

关于docker - 构建Jenkins Docker镜像失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44432616/

10-16 16:12