#!/bin/bash
tomcat_path=/usr/local/tomcat/apache-tomcat-9.0.7/webapps
restart_tomcat_sh_path=/opt/run_/tomcat/general-control/
restart_tomcat_sh_name=restart.sh
source_path=${JENKINS_HOME}"/workspace/equipments_manage"
project=equipments_manage
war_path=${JENKINS_HOME}"/workspace/equipments_manage/service-module/remote-manager/target/"
war_name=mymanager.war
war_file=${war_path}${war_name}
log_file=${JENKINS_HOME}"/build_log.log"
writeLogFun(){
if [ ! -e $log_file ]
then
echo "文件不存在 新建一个"
touch ${log_file}
fi
nowtime=`date +%Y%m%d%H%M%S`
echo $nowtime$1 >> $log_file
}
writeLogFun "开始执行 mvn install命令当前路径$(pwd)"
mvn -f ${source_path}/pom.xml install
if [ -e $war_file ]
then
writeLogFun "检测到war包的存在"
writeLogFun "移动${war_file}到${tomcat_path}"
mv ${war_file} ${tomcat_path}
sleep 1s
writeLogFun "移动到重启脚本路径下 启动脚本"
cd $restart_tomcat_sh_path
writeLogFun "执行 mvn clean"
mvn -f ${source_path}/pom.xml clean
else