Online script #!/bin/bashfwdir= "$ (cd ' dirname " ${bash_source-$0} "'; pwd)" Bin= ' dirname "$" ' bin= ' CD "$bin"; pwd ' now= ' date "+%y%m%d_%h%m%s" ' tag_release=di.release.${now}[email protected]: bdp-server/bdp-di.gitecho -e "\033[32m=====> build release tag\033[0m" git clone $repo _url $tag _releasecd $tag _release# on-line branch, if not transmitted to the online master[[ $# -eq 1 ]] && git checkout di_$1git tag -a ${tag_release} -m "${tag_release} tagged from branch master" Git push origin ${tag_ release}# Extract version information 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 .gitecho -e " \033[32m=====> stop the old service... \033[0m "cd $bin/service/binbash di.sh stopecho -e " \033[32m=====> start new service...\033[0m "cd $binrm -rf serviceln -s ${tag_release} servicecd $bin/service/binbash di.sh start# Send online log mail echo -e "${tag_release} version on-line description (online environment) \n==================================\n version Summary: ${release_note} \n on-line description:\n\n1. " > $FWDIR/note.tmpvi $FWDIR/note.tmp +mail -s "bdp-di online log" ${tag_release} [ email protected] < $FWDIR/note.tmprm $FWDIR/note.tmp
Rollback script #!/bin/bashbin= ' dirname ' $ "' bin= ' CD" $bin "; PWD ' [[[$#-eq 0]] && echo "usage:$0 {version}" && exit 0version= "di.release.$1" Echo-e "\033[32m=====> Stop the Old service...\033[0m "CD $bin/service/binbash di.sh stopecho-e" \033[32m=====> start new service...\033[0m "CD $BINRM-rf serviceln-s ${version} servicecd $bin/service/binbash di.sh startecho-e" \033[32m=====> success to Ro Llback to $version \033[0m "#send mailecho-e ' Bdp-di version rollback (online environment) \ n ' ==================================\n ' was rolled back to version: ' ${ Version} | Mail-s "Bdp-di rollback log" [email protected]
Line code, rollback code