maven更新到3.6步骤:
1、打包新的maven
2、根据打包的镜像,在kubesphere-devops-system命名空间下去修改configmap的jenkins-casc-config里对应的podTemplate
3、在jenkins->configuration as code重载加载已有配置
配置文件如下所示:
1、Dockerfile
FROM kubesphere/builder-base:v2.1.1
# java
RUN yum install -y java-11-openjdk.x86_64 \
java-11-openjdk-devel.x86_64
# maven
ENV MAVEN_VERSION 3.6.3
RUN curl -f -L 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
COPY settings.xml /opt/apache-maven-$MAVEN_VERSION/.m2/settings.xml
COPY settings.xml /opt/apache-maven-$MAVEN_VERSION/conf/settings.xml
ENV M2_HOME /opt/apache-maven-$MAVEN_VERSION
ENV maven.home $M2_HOME
ENV M2 $M2_HOME/bin
ENV PATH $M2:$PATH
# ant
#https://downloads.apache.org/ant/binaries/apache-ant-1.10.9-bin.tar.gz
ENV ANT_VERSION 1.10.9
RUN cd && \
wget -q http://downloads.apache.org/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && \
tar -xzf apache-ant-${ANT_VERSION}-bin.tar.gz && \
mv apache-ant-${ANT_VERSION} /opt/ant && \
rm apache-ant-${ANT_VERSION}-bin.tar.gz
ENV ANT_HOME /opt/ant
ENV PATH ${PATH}:/opt/ant/bin
# Set JDK to be 32bit
# COPY set_java $M2
# RUN $M2/set_java && rm $M2/set_java
CMD ["mvn","-version"]
2、settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- <localRepository>/Users/jiaheng/.m2/repository</localRepository> -->
<servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>xxxxxxxxx</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>xxxxxxxxxx</password>
</server>
<!--<server>-->
<!--<id>nexus-thirdparty</id>-->
<!--<username>admin</username>-->
<!--<password>xxxxxxxx</password>--> <!--</server>-->
</servers>
<mirrors>
<mirror>
<id>dao</id>
<name>dao maven</name>
<url>http://nexus.xxxxxx.int/repository/maven-public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<url>http://nexus.xxxxxx.int/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<url>http://nexus.xxxxxx.int/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
3、set_java (optional)
#!/bin/bash
# credit https://github.com/jerboaa from https://github.com/fabric8io-images/maven-builder/blob/d81dedbc298dee7e071ac2bc1e0050ae7ee1e5aa/set_java
ARCH=$(uname -m)
echo $ARCH
if [[ ${ARCH} == 'x86_64' ]]; then
JAVA_32=$(alternatives --display java | grep family | grep i386 | cut -d' ' -f1)
alternatives --set java ${JAVA_32}
JAVAC_32=$(alternatives --display javac | grep family | grep i386 | cut -d' ' -f1)
# Maven actually uses javac, not java
alternatives --set javac ${JAVAC_32}
exit $?
fi
_