Send files or execute commands over SSH

1、将war包发送到目标服务器,并执行shell脚本(前提是自动打包成功后)



2、利用shell脚本 控制tomcat启停 和 项目部署

#export JAVA_HOME=/usr/local/jdk1.6.0_45
export DEPLOYMENT_HOME=//usr/local/jenkins-deploy/target
export USERPORTAL_HOME=/usr/local/apache-tomcat-7.0.78-hangye

echo "[Deploy] Shutting down hangye tomcat 1"
if [ `ps auxwwww|grep apache-tomcat-7.0.78-hangye|grep -v grep|wc -l` -gt 0 ]
then
for pid in `ps auxwww|grep apache-tomcat-7.0.78-hangye|grep -v grep|tr -s ' '|cut -d ' ' -f2`
do
kill -9 $pid 2>&1 > /dev/null
done
fi

echo "[Deploy] Cleaning cache for hangye tomcat 1"
rm -rf $USERPORTAL_HOME/work/Catalina/localhost/*

echo "[Deploy] Removing old war"
rm -rf $USERPORTAL_HOME/webapps/hangye*

echo "[Deploy] Copying new war"
mv $DEPLOYMENT_HOME/jeecg.war $USERPORTAL_HOME/webapps/hangye.war

echo "[Deploy] Starting up hangye tomcat 1"
$USERPORTAL_HOME/bin/startup.sh


Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐