Jenkins+Maven部署安装
Jenkins官方地址:
Jenkins官方文档:
Maven官方下载:
一、Jenkins安装
1、安装jdk11环境
yum -y install java-11-openjdk.x86_64
java -version
2、下载 && 安装 && 启动
wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/jenkins-2.379-1.1.noarch.rpm --no-check-certificate
rpm -ivh jenkins-2.379-1.1.noarch.rpm
systemctl start jenkins.service
3、查看密码 && 网页登入
cat /var/lib/jenkins/secrets/initialAdminPassword
浏览器访问:http://localhost:8080
输入密码
选择先不安装插件,因为Jenkins服务器在国外,国内访问太慢了,后续使用离线方式安装
插件离线安装参考:Jenkins插件离线安装
二、Maven安装
1、下载二进制包
wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
tar zxf apache-maven-3.8.6-bin.tar.gz
mv apache-maven-3.8.6 /usr/local/maven
2、配置阿里源
cd /usr/local/maven
mkdir repository
vim conf/settings.xml
... ...
<!-- 添加下面这行 -->
<localRepository>/usr/local/maven/repository</localRepository>
<!-- 修改mirror如下 -->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
3、配置环境变量
vim /etc/profile
... ...
export M2_HOME=/usr/local/maven
export PATH=$PATH:$M2_HOME/bin
source /etc/profile
mvn -v
4、构建jar包
cd 源码路径
mvn clean package