系统环境 系统版本:Centos7.9
docker安装参考此链接:
一、安装Maven
因为用到的docker镜像中不包含maven,所以要在容器里安装maven,把下载好的maven包传进服务器中
1.1 把下载好的maven包传进服务器中
dfc@BBC-xxc ~ % scp /Users/dfc/Library/Containers/com.tencent.xinWeChat/Data/Library/Application\ Support/com.tencent.xinWeChat/2.0b4.0.9/8f3459f55f57e8f624ecba5da6564b5f/Message/MessageTemp/6fcb9ab864d6f647e050d2ccfc35165a/File/apache-maven-3.8.5-bin.tar.gz root@192.168.10.34:/abb
1.2 解压
tar -xzvf apache-maven-3.8.5-bin.tar.gz
1.3 拷贝进docker 中的Jenkins容器下的/maven/目录下
[root@redis02 ~]# docker cp /abb/apache-maven-3.8.5 Jenkins:/maven/
1.4 修改国内源,配置settings.xml 新建一个settings.xml文件
vim settings.xml
写入
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http:
http:
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>阿里云公共仓库</name>
<url>https:
</mirror>
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>central repo</name>
<url>http:
</mirror>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>apache snapshots</mirrorOf>
<name>阿里云阿帕奇仓库</name>
<url>https:
</mirror>
</mirrors>
<proxies/>
<activeProfiles/>
<profiles>
<profile>
<repositories>
<repository>
<id>aliyunmaven</id>
<name>aliyunmaven</name>
<url>https:
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>MavenCentral</id>
<url>http:
</repository>
<repository>
<id>aliyunmavenApache</id>
<url>https:
</repository>
</repositories>
</profile>
</profiles>
</settings>
替换掉原来的settings.xml文件,原来的settings.xml文件在/maven/apache-maven-3.8.5/conf/ 下
[root@redis02 ~]# docker cp settings.xml jenkins:/maven/apache-maven-3.8.5/conf/ #同样的文件名,会覆盖掉之前的
在容器中进入
root@38d0cecdc58b:/etc# ls /maven/apache-maven-3.8.5/bin/
验证maven安装
root@38d0cecdc58b:/etc# /maven/apache-maven-3.8.5/bin/mvn -v
Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
Maven home: /maven/apache-maven-3.8.5
Java version: 11.0.14.1, vendor: Eclipse Adoptium, runtime: /opt/java/openjdk
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.62.1.el7.x86_64", arch: "amd64", family: "unix"
创建软连接(不需要进入到原来的路径也可以验证Maven安装)
root@38d0cecdc58b:/etc# ln -s /maven/apache-maven-3.8.5/bin/mvn /usr/local/bi`n/
重新验证Maven安装
root@38d0cecdc58b:/etc# mvn -v
Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
Maven home: /maven/apache-maven-3.8.5
Java version: 11.0.14.1, vendor: Eclipse Adoptium, runtime: /opt/java/openjdk
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.62.1.el7.x86_64", arch: "amd64", family: "unix"
|