3-jenkins安装maven编译打包
1、jenkins服务器安装maven并配置仓库
maven官网下载地址:https://maven.apache.org/download.cgi
wget https://dlcdn.apache.org/maven/maven-3/3.8.2/binaries/apache-maven-3.8.2-bin.tar.gz
解压:tar -xvf apache-maven-3.8.2-bin.tar.gz
mkdir -p /opt/maven
mv apache-maven-3.8.2/* /opt/maven
#环境变量配置
vi /etc/profile 添加如下配置
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
export MAVE_HOME=/opt/maven
export PATH=
P
A
T
H
:
PATH:
PATH:JAVA_HOME/bin:$MAVE_HOME/bin
source /etc/profile
mvn -v
2、全局工具配置关联JDK和Maven
jenkins–>Global Tool Configuration–>JDK–>新增JDK,配置如下:
3、添加jenkins全局变量
Manage Jenkins–>Configure System–>Global Properties,添加三个全局变量
JAVA_HOME、M2_HOME、PATH+EXTRA
4、修改Maven的settings.xml
mkdir /opt/repo 创建本地仓库目录
vi /opt/maven/conf/settings.xml
本地仓库地址改为:/opt/repo
添加阿里云私服地址:
1、打开setting.xml,找到标签
2、在标签中增加如下代码:
nexus-aliyun
*
Nexus aliyun
http://maven.aliyun.com/nexus/content/groups/public
5、jenkins项目使用maven打包
mvn clean package