下载并配置maven
wget https://mirrors.bfsu.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
tar -xzf apache-maven-3.6.3-bin.tar.gz
mkdir -p /opt/maven
mv apache-maven-3.6.3/* /opt/maven
#**配置环境变量**
vi /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
export MAVEN_HOME=/opt/maven
export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
source /etc/profile
mvn -v
Jenkin关联JDK和Maven
全局工具配置
Jenkins->Global Tool Configuration->JDK->新增JDK,配置如下:
Jenkins->Global Tool Configuration->Maven->新增Maven,配置如下:
点击应用保存即可
添加Jenkins全局变量
Manage Jenkins->Configure System->Global Properties ,添加三个全局环境变量JAVA_HOME、M2_HOME、PATH+EXTRA
JAVA_HOME:/usr/lib/jvm/java-1.8.0-openjdk
M2_HOME:/opt/maven
PATH+EXTRA:$M2_HOME/bin
修改Maven的settings.xml
mkdir /root/repo # 创建本地仓库目录
vi /opt/maven/conf/settings.xml
# 本地仓库改为:/root/repo/
#添加阿里云私服地址:
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
安装Pipeline插件
Manage Jenkins->Manage Plugins->可选插件–>安装Pipeline
安装完成之后,创建项目的时候会出现流水线项目