Jenkins——增加应用编译部署
新建Item:
源码配置:
构建环境配置:
#!/usr/bin/bash source /etc/profile tomcat_home="/home/mppay/apache-tomcat-8.5.40-monitor/" folder="/opt/backup" uploadfolder="/opt/upload" SHUTDOWN=$tomcat_home/bin/shutdown.sh STARTTOMCAT=$tomcat_home/bin/startup.sh project=monitor if [ -d folder ];then echo "文件夹存在" else mkdir folder fi echo "close $tomcat_home" #$SHUTDOWN ps -ef |grep tomcat |grep $tomcat_home |grep -v 'grep'|awk '{print $2}' | xargs kill -9 #删除tomcat的临时目录 rm $tomcat_home/work/* -rf TODAY=`date +%Y%m%d` echo $TODAY if [ ! -d "$folder" ]; then mkdir "$folder" fi if [ ! -d "$folder"/"$TODAY" ]; then mkdir "$folder"/"$TODAY" fi echo '----begin backup--------' mppay_bak="$project"${TODAY}".tar" cd "$tomcat_home"/"webapps" tar -cvf "$mppay_bak" "$project" cp "${mppay_bak}" "$folder"/"$TODAY" rm -rf "$project".war echo "----rm -rf "$project".war--------" rm -rf "$project" echo "---rm -rf "$project"--------" echo "----end backup--------" echo "------------" "$folder"/"$TODAY" cd "$uploadfolder" cp "$project".war "$tomcat_home"/"webapps" sleep 3 echo "stattup $tomcat_home" $STARTTOMCAT
编译配置: