shell腳本,自動從git服務器下載代碼,運用maven編譯成war包,部署到resin
#! /bin/sh
base=/home/shenyun/git/myproject
cd $base
#獲取代碼
git pull
#如果最後運行的命令的結束代碼(返回值)不爲0,返回
if [ ! $? -eq 0 ]
then
echo "Error in git pull!!! Stop deployment!"
exit 1
fi
cd $base
mvn clean package -Dmaven.test.skip=true
/usr/local/resin/bin/resin.sh stop
cp $base/target/myproject.war /usr/local/resin/webapps/
#或者解壓
#unzip $base/target/myproject.war -d /usr/local/resin/webapps/myproject
/usr/local/resin/bin/resin.sh start
echo [info] web packaging over!!