简单使用shell 自动打包,发布项目 脚本
(1)打包,发布脚本
deploy.sh
packagepath=/home/admin/testProject/project application=testProject mkdir -p $packagepath cd $packagepath || exit [ -d $packagepath/$application ] || git clone git@git.hello.so:powergreen/${application}.git [ -d $packagepath/$application/.git ] || ( rm -rf $packagepath/$application/ && git clone git@git.hello.so:powergreen/${application}.git ) cd $packagepath/$application || exit git checkout dev git pull # generate a folder and a file which named xx.war, such as lhc lhc.war # under the folder $application-web/target # we just need the .war file mvn clean package -Dmaven.test.skip -U -Pdev -e cd $packagepath/$application/testProject-web/target/ java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=9091,suspend=n -jar testProject.jar &
关闭进程脚本
stop.sh(要输入进程的名称
#! /bin/bash if [ $# -lt 1 ] then echo "缺少参数:procedure_name" exit 1 fi PROCESS=`ps -ef|grep $1|grep -v grep|grep -v PPID|awk '{ print $2}'` for i in $PROCESS do echo "Kill the $1 process [ $i ]" kill -9 $i done
bulid.sh 执行bulid.sh [start|stop] 开始打包发布脚本
命令 : ./bulid.sh start 发布项目
./bulid.sh stop 停止项目
#! /bin/bash sOn=$1 name=testProject echo "执行操作:$sOn" if test $sOn = "start"; then echo '停止${name}' source /home/admin/testProject/scripts/stop.sh ${name} echo '开始启动${name}' source /home/admin/testProject/scripts/deploy.sh exit 1 else if test $sOn = "stop"; then echo '停止${name}' source /home/admin/testProject/scripts/stop.sh ${name} exit 1 else echo '参数错误' exit 1 fi
fi