Last active
November 9, 2017 08:42
-
-
Save wulinjie122/a710c53e9e4c85e1db142074d89400fd to your computer and use it in GitHub Desktop.
自动打包并部署WAR包(auto deploy war file to tomcat)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read -p "please input your branch name, e.g. dev " branch | |
if [ n "$branch"]; then | |
# if no branch name, master as default | |
branch="master" | |
fi | |
# shutdown tomcat | |
echo "shutdown tomcat" | |
sh /usr/local/tomcat/bin/shutdown.sh | |
fuser -k 8080/tcp | |
fuser -k 8009/tcp | |
#echo "backup previous war file" | |
echo "update project code" | |
cd ~/project/AMS/ | |
git fetch | |
git checkout $branch | |
git pull origin $branch | |
echo "start to compile sourcecode" | |
mvn -Dmaven.test.skip=true clean package -U | |
# find target war file | |
WARFILE=$(find /root/project/AMS/ams-web/target -name "*.war" | xargs awk 'END{ var=FILENAME; n=split (var,a,/\//); print a[n]}') | |
echo "start deploy war file" | |
rm -rf /usr/local/tomcat/webapps/ams-web/* | |
cp ~/project/AMS/ams-web/target/$WARFILE /usr/local/tomcat/webapps/ams-web/ | |
cd /usr/local/tomcat/webapps/ams-web/ | |
echo "decompress $WARFILE" | |
jar -xf $WARFILE | |
rm /usr/local/tomcat/webapps/ams-web/$WARFILE | |
echo "replace shiro file" | |
cp /root/project/local_config/ams-web-shiro.properties /usr/local/tomcat/webapps/ams-web/WEB-INF/classes/shiro.properties | |
cd ~ | |
echo "startup tomcat" | |
sh /usr/local/tomcat/bin/startup.sh | |
echo "start tomcat successed, output log" | |
tail -f /usr/local/tomcat/logs/catalina.out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find special file and move to another dictory | |
find /root/project/AMS/ams-web/target -name "*.war" -print0 | xargs -0 -I {} mv {} /usr/local/tomcat/webapps/ams-web/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#老铁,66666