我使用Dockerfile在动态Jenkins代理节点上安装maven。我能够成功构建并启动容器,而不会出现任何错误。但是,当我使用“ docker exec -it”登录容器时,我看不到maven。但是我能够在容器内手动关闭专家。由于没有错误,所以无法猜测我在哪里做错了。
尝试将其成功下载为apache * .tar.gz格式。
FROM jenkins/jnlp-slave:alpine as jnlp
FROM node:alpine
ENV JAVA_HOME /usr/lib/jvm/default-jvm
RUN apk add --no-cache openjdk8 && \
ln -sf "${JAVA_HOME}/bin/"* "/usr/bin/"
COPY --from=jnlp /usr/local/bin/jenkins-slave /usr/local/bin/jenkins-agent
COPY --from=jnlp /usr/share/jenkins/slave.jar /usr/share/jenkins/slave.jar
ARG MAVEN_VERSION=3.6.1
USER root
RUN mkdir -p /home/jenkins \
&& cd /home/jenkins \
&& wget https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz -O - | tar xzf - -C /home/jenkins \
&& mv /home/jenkins/apache-maven-$MAVEN_VERSION /home/jenkins/maven
RUN ln -s /home/jenkins/maven/bin/mvn /usr/bin/mvn
ENTRYPOINT ["/usr/local/bin/jenkins-agent"]
我应该能够执行mvn -version