gpt4 book ai didi

jenkins - 在 jenkins 中使用 docker-build-step 插件构建 dockerfile 时 ADD 命令失败

转载 作者:行者123 更新时间:2023-12-02 10:36:21 25 4
gpt4 key购买 nike

以下是我的 DockerFile

FROM centos:centos6
MAINTAINER Priyanka

################## Helpful utils
RUN yum -y install sudo
RUN yum -y install curl
RUN yum -y install unzip

################## JDK7

#Note that ADD uncompresses this tarball automatically
ADD jdk-7u79-linux-x64.tar.gz /opt
WORKDIR /opt/jdk1.7.0_79
RUN alternatives --install /usr/bin/java java /opt/jdk1.7.0_79/bin/java 1
RUN alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_79/bin/jar 1
RUN alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_79/bin/javac 1
RUN echo "JAVA_HOME=/opt/jdk1.7.0_79" >> /etc/environment
ENV JAVA_OPTS -Xms1024m -Xmx4196m -XX:NewSize=256m -XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=356m

################## TOMCAT

#Note that ADD uncompresses this tarball automatically
ADD apache-tomcat-7.0.67.tar.gz /usr/share
WORKDIR /usr/share/
RUN mv apache-tomcat-7.0.67 tomcat7
RUN echo "JAVA_HOME=/opt/jdk1.7.0_79/" >> /etc/default/tomcat7
RUN groupadd tomcat
RUN useradd -s /bin/bash -g tomcat tomcat
RUN chown -Rf tomcat.tomcat /usr/share/tomcat7
EXPOSE 8087

################## ROC Client War Download

RUN curl -O http://10.113.57.164:8080/job/ROC4.0_Client/ws/spark-web/entrypoint/target/entrypoint.war
RUN unzip entrypoint.war -d /usr/share/tomcat7/webapps/roc_client
ADD validation-api-1.1.0.Final.jar /usr/share/tomcat7/webapps/roc_client/WEB-INF/lib/
ADD validation-api-1.1.0.Final-sources.jar /usr/share/tomcat7/webapps/roc_client/WEB-INF/lib/
RUN rm /usr/share/tomcat7/webapps/roc_client/WEB-INF/lib/validation-api-1.0.0.GA-sources.jar
RUN rm /usr/share/tomcat7/webapps/roc_client/WEB-INF/lib/validation-api-1.0.0.GA.jar

################## Tomcat launch

CMD ["/usr/share/tomcat7/bin/catalina.sh","run"]

在 Jenkins 中使用 docker-build-step 构建此文件时,构建失败,并在 ADD 处出现以下异常

Step 0 : FROM centos:centos6

---> 3bbbf0aca359

Step 1 : MAINTAINER Priyanka

---> Using cache

---> c8055ba8439a

Step 2 : RUN yum -y install sudo

---> Using cache

---> 203da82ad2af

Step 3 : RUN yum -y install curl

---> Using cache

---> c6cb08257236

Step 4 : RUN yum -y install unzip

---> Using cache

---> 688620db641a

Step 5 : ADD jdk-7u79-linux-x64.tar.gz /opt

ERROR: Build step failed with exception
java.lang.RuntimeException: java.lang.ClassCastException: org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl cannot be cast to javax.json.JsonString
at org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand.execute(CreateImageCommand.java:139)
at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder.perform(DockerBuilder.java:75)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Caused by: java.lang.ClassCastException: org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl cannot be cast to javax.json.JsonString
at org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl.getJsonString(JsonObjectBuilderImpl.java:194)
at org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl.getString(JsonObjectBuilderImpl.java:199)
at org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand$1.callback(CreateImageCommand.java:123)
at org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand.readJsonStream(CreateImageCommand.java:161)
at org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand.execute(CreateImageCommand.java:115)
... 10 more
Build step 'Execute Docker command' marked build as failure
Finished: FAILURE

我已经多次运行此构建,并且成功运行,没有任何问题。我对构建配置进行了一些临时更改并恢复了。从那时起它就抛出这个错误。尝试从文件中删除所有 docker 命令,只保留一个 RUN 命令。仍然是同样的问题。它无法运行任何 docker 命令。

最佳答案

我也遇到了同样的问题。实际上,您正在查找的文件不存在于您的工作区作业目录中。如果您的 docker-step-plugin 可以找到该文件,则 Dockerfile 中的命令 ADD 将起作用:-)希望这有帮助。

关于jenkins - 在 jenkins 中使用 docker-build-step 插件构建 dockerfile 时 ADD 命令失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36150444/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com