标签:
上线脚本 #!/bin/bash FWDIR="$(cd `dirname "${BASH_SOURCE-$0}"`; pwd)" bin=`dirname "$0"` bin=`cd "$bin"; pwd` now=`date "+%Y%m%d_%H%M%S"` tag_release=di.release.${now} repo_url=git@git.beijing.com:bdp-server/bdp-di.git echo -e "\033[32m=====> build release tag\033[0m" git clone $repo_url $tag_release cd $tag_release #上线分支,如果不传参则上线master [[ $# -eq 1 ]] && git checkout di_$1 git tag -a ${tag_release} -m "${tag_release} tagged from branch master" git push origin ${tag_release} # 提取版本信息 commiter=$(git for-each-ref --format="%(committername)" refs/heads) release_note=$(git for-each-ref --format="%(committername)@%(refname:short) [%(committerdate:short)] %(contents)" refs/heads) rm -rf .git echo -e "\033[32m=====> stop the old service...\033[0m" cd $bin/service/bin bash di.sh stop echo -e "\033[32m=====> start new service...\033[0m" cd $bin rm -rf service ln -s ${tag_release} service cd $bin/service/bin bash di.sh start # 发送上线日志邮件 echo -e "${tag_release} 版本上线说明(线上环境)\n==================================\n版本摘要:${release_note} \n上线说明:\n\n1. " > $FWDIR/note.tmp vi $FWDIR/note.tmp + mail -s 【BDP-DI上线日志】${tag_release} bdpteam@beijing.com < $FWDIR/note.tmp rm $FWDIR/note.tmp
回滚脚本 #!/bin/bash bin=`dirname "$0"` bin=`cd "$bin"; pwd` [[ $# -eq 0 ]] && echo "Usage:$0 {version}" && exit 0 version="di.release.$1" echo -e "\033[32m=====> stop the old service...\033[0m" cd $bin/service/bin bash di.sh stop echo -e "\033[32m=====> start new service...\033[0m" cd $bin rm -rf service ln -s ${version} service cd $bin/service/bin bash di.sh start echo -e "\033[32m=====> success to rollback to $version\033[0m" #send mail echo -e ‘BDP-DI版本回滚(线上环境)\n‘‘==================================\n‘‘已回滚至版本:‘${version} | mail -s 【BDP-DI回滚日志】bdpteam@beijing.com
标签:
原文地址:http://my.oschina.net/yulongjiang/blog/469451