①:在Linux中安装Git
yum list git
列出git安装包
yum install git
在线安装git
[rootalocalhost ~]yum list git
Loaded plugins:fastestmirror
Loading mirror speeds from cached hostfile
base:mirrors.bfsu.edu.cn
extras:mirrors.bfsu.edu.cn
updates:mirrors.bfsu.edu.cn
Available Packages
git.x86 64
1.8.3.1-23.e17_8
②:使用Git克隆代码
cd xxx
git clone xxxxxxx
Shell脚本bootstart.sh
#!/bin/sh
echo =================================
echo 自动化部署脚本启动
echo =================================
echo 停止原来运行中的工程,项目名为linux
APP_NAME=linux
tpid='ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}''
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 2
tpid='ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}''
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
echo 准备从Git仓库拉取最新代码,linux为项目名
cd /usr/local/linux
echo 开始从Git仓库拉取最新代码
git pull
echo 代码拉取完成
echo 开始打包
output='mvn clean package -Dmaven.test.skip=true'
cd target
echo 启动项目
nohup java -jar linux-0.0.1-SNAPSHOT.jar &> linux.log &
echo 项目启动完成