1安装
1.1 jdk1.5以上。
1.2
https://www.jenkins.io/zh/download/
-
版本说明
LTS版本为稳定版,非LTS版本为测试版
java 1.8 tomcat 8.0
2配置
2.1 基础配置
2.2全局配制
tomcat配置、
tomcat
deployTime=`date +'%Y%m%d%H%M%S'`
deployFormartTime=`date +'%Y-%m-%d %H:%M:%S'`
server_path='/usr/local/tomcat8'
jar_tep='/usr/local/appServer'
server_name='/usr/local/tomcat8/webapps/ROOT.war'
server_name_de='/usr/local/tomcat8/webapps/ROOT'
echo "开始执行$deployFormartTime" >> $jar_tep/log.txt
${server_path}/bin/shutdown.sh
tomcat_id=$(ps -ef |grep tomcat |grep -w ${server_path}|grep -v 'grep'|awk '{print $2}')
echo "开始关闭原有程序tomcat_id=$tomcat_id" >> $jar_tep/log.txt
if [ "$tomcat_id" == "" ]
then
echo -e "\033[32m已关闭Tomcat...\033[0m" >> $jar_tep/log.txt
else
echo -e "\033[0m\033[32m强制关闭Tomcat...\033[0m" >> $jar_tep/log.txt
sleep 1s
ps -ef |grep tomcat |grep -w ${server_path}|grep -v 'grep'|awk '{print $2}'|xargs kill -s 9
fi
echo "关闭原有程序完成" >> $jar_tep/log.txt
sleep 500ms
tomcat_id=$(ps -ef |grep tomcat |grep -w ${server_path}|grep -v 'grep'|awk '{print $2}')
echo "关闭之后tomcat_id=$tomcat_id" >> $jar_tep/log.txt
mv $server_name $jar_tep/${deployTime}.zip
echo "备份jar包完成" >> $jar_tep/log.txt
mv ${server_path}/deploy/ROOT.war ${server_path}/webapps/ROOT.war
rm -r $server_name_de
echo "删除ROOT完成" >> $jar_tep/log.txt
echo "移动jar包完成" >> $jar_tep/log.txt
${server_path}/bin/startup.sh >> $jar_tep/log.txt 2>&1
sleep 500ms
echo "启动jar包完成" >> $jar_tep/log.txt
tomcat_id=$(ps -ef |grep tomcat |grep -w ${server_path}|grep -v 'grep'|awk '{print $2}')
echo "启动之后tomcat_id=$tomcat_id" >> $jar_tep/log.txt
sleep 500ms
echo "结束" >> $jar_tep/log.txt
jar
deployTime=`date +'%Y%m%d%H%M%S'`
server_path='/usr/local/tanker_server/mem'
jar_tep='/usr/local/tanker_server/mem/mem'
server_name='/usr/local/tanker_server/mem/memServer.jar'
echo "开始执行$tomcat_home" >> $jar_tep/log.txt
source /etc/profile
tomcat_id=$(ps -ef |grep $server_name|grep -v 'grep'|awk '{print $2}')
echo "开始关闭原有程序tomcat_id=$tomcat_id" >> $jar_tep/log.txt
ps -ef|grep $server_name|grep -v grep|awk '{print $2}'|xargs kill -s 9
echo "关闭原有程序完成" >> $jar_tep/log.txt
sleep 500ms
tomcat_id=$(ps -ef |grep $server_name|grep -v 'grep'|awk '{print $2}')
echo "关闭之后tomcat_id=$tomcat_id" >> $jar_tep/log.txt
mv $server_name $server_path/carTep/${deployTime}.zip
echo "备份jar包完成" >> $jar_tep/log.txt
mv $jar_tep/car.jar $server_name
echo "移动jar包完成" >> $jar_tep/log.txt
BUILD_ID=dontKillMe
nohup java -jar $server_name --spring.profiles.active=test1 > $server_path/logs/log.txt &
sleep 500ms
echo "启动jar包完成" >> $jar_tep/log.txt
tomcat_id=$(ps -ef |grep $server_name|grep -v 'grep'|awk '{print $2}')
echo "启动之后tomcat_id=$tomcat_id" >> $jar_tep/log.txt
sleep 500ms
echo "结束" >> $jar_tep/log.txt