目前项目使用的是jdk17,想使用kubesphere devops
注意:
找到jenkins-casc-config 配置后,改动用户文件才有效,修改完成等待大概2两钟
- name: "mavenjdk11" label: "jdk11 maven java" inheritFrom: "maven" containers: - name: "maven" image: "registry.cn-beijing.aliyuncs.com/kubesphereio/builder-maven:v3.2.1-jdk11" - name: "mymavenjdk17" label: "mavenjdk17" inheritFrom: "maven" containers: - name: "maven" image: "你构建的镜像地址"
使用dockerfile构建镜像,上传到dockerHub或者私有云仓库
# 使用基础镜像,请注意,一定要使用builder-base,jenkins再走流程的时候,需要有docker 的命令 FROM registry.cn-beijing.aliyuncs.com/kubesphereio/builder-base:v3.2.2 # 设置环境变量 ENV MAVEN_VERSION=3.9.7 ENV PATH_NAME=jdk-17.0.13+11 ENV TZ=Asia/Shanghai # 设置时区 RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # 移除现有的 JDK 8 RUN if [ -d /usr/lib/jvm ]; then rm -rf /usr/lib/jvm/*; fi # 下载并安装 OpenJDK 17 RUN mkdir -p /usr/lib/jvm && curl -f -L -o /tmp/$PATH_NAME.tar.gz https://mirrors.tuna.tsinghua.edu.cn/Adoptium/17/jdk/x64/linux/OpenJDK17U-jdk_x64_linux_hotspot_17.0.13_11.tar.gz && tar -xzf /tmp/$PATH_NAME.tar.gz -C /usr/lib/jvm && rm /tmp/$PATH_NAME.tar.gz # 设置 Java 环境变量 ENV JAVA_HOME /usr/lib/jvm/$PATH_NAME ENV PATH $JAVA_HOME/bin:$PATH # 验证 Java 安装 RUN java -version # 安装 Maven RUN curl -f -L https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar -C /opt -xzv ENV MAVEN_HOME=/opt/apache-maven-$MAVEN_VERSION ENV PATH $MAVEN_HOME/bin:$PATH # 验证 Maven 安装 RUN mvn -v # 设置默认命令 CMD ["mvn"]