1:首先确定了LINUX上已安装SVN MAVEN
2: 把SVN项目CHECKOUT到LINUX服务器
svn checkout svn://172.17.210.82:9999/xxx --username zhang.lh --password xx
3:脚本
1:
#!/bin/sh
#Description:oms发布脚本
#Version:1.0
#Author:dong.j
#Date:2013-12-17
source /etc/profile
#初始化
function init(){
svn_home="/root/retail/mobil-platform/o2o-mobile-access-platform-0.1.0"
project_name="o2o-mobile-access-platform-web"
#project_conf_home="/etc/yougouconf/retail/pmsf1/"
project_deploy_home="/usr/local/yougou/mobil-platform/" #项目存放路径
tomcat_home="/usr/local/apache-tomcat-7.0.37-test"
}
#逻辑实现
function logicImpl(){
sh retail_common_test.sh "$svn_home" "$project_name" "$project_conf_home" "$project_deploy_home" "$tomcat_home"
}
#主函数
function main(){
init
logicImpl
}
main
2:
#!/bin/sh
#Description:发布脚本
#Version:1.1
#Author:dong.j
#Date:2013-12-16
#Usage:sh publish.sh svn_home project_name project_conf_home project_deploy_home tomcat_home
source /etc/profile
#初始化
function init(){
svn_home="$1"
project_name="$2"
project_conf_home="$3"
project_deploy_home="$4"
tomcat_home="$5"
tomcat_process_id="`ps -ef | grep /usr/local/apache-tomcat-7.0.37-test | grep -v 'grep' | awk '{print $2}'`"
theDay=`date +%Y%m%d -d "1 days ago "`
}
#启动tomcat
function startTomcat(){
echo "################# start tomcat"
sh $tomcat_home/bin/startup.sh >>/dev/null 2>&1
}
#关闭tomcat
function shutdownTomcat(){
echo "################# shutdown tomcat"
sh $tomcat_home/bin/shutdown.sh >>/dev/null 2>&1
}
#操作tomcat
function tomcatManager(){
echo "################# tomcatManger"
case $1 in
"start")
if [ "$tomcat_process_id" != "0" ]
then
shutdownTomcat
sleep 3
fi
startTomcat
;;
"shutdown")
if [ "$tomcat_process_id" != "0" ]
then
shutdownTomcat
fi
;;
*)
echo "请输入Tomcat操作命令start or shutdown"
;;
esac
sleep 3
}
#svn更新
function update(){
echo "update svn"
echo "$project_name update svn ...."
cd $svn_home
svn update
echo -e "\n$project_name update svn success...."
}
#maven 打包
function package(){
echo "package maven"
echo "$project_name package is begging...."
mvn clean package -Dmaven.test.skip=true >>/dev/null 2>&1
echo "$project_name package success...."
}
#复制上传文件到对应项目目录
function copyFile(){
echo "copy file is begging"
#rm -rf $project_conf_home $project_deploy_home
rm -rf $project_deploy_home
#cp -rf conf/retail/${project_name} ${project_conf_home}
cp -rf o2o-mobile-access-platform-web/target/o2o-mobile-access-platform-web ${project_deploy_home}
}
#逻辑实现
function logicImpl(){
tomcatManager "shutdown"
update
package
echo "$project_name is begging publish...."
copyFile
tomcatManager "start"
echo "$project_name publish success...."
}
#主函数
function main(){
init "$1" "$2" "$3" "$4" "$5"
logicImpl
}
main "$1" "$2" "$3" "$4" "$5"
4:配置TOMCAT 发布路径