发布脚本(带git版本号)

xiaoxiao2025-10-17  10

while getopts ":e:s:a:" opt do case $opt in e) env=$OPTARG ;; s) server=$OPTARG ;; a) author=$OPTARG ;; ?) echo "未知参数" exit 1;; esac done deploy() { #发布路径 deployPath=/opt/formal_packge/$env/hotpot-fb-overseas #war打包路径 buildPath=hotpot-web/build/libs/hotpot-web.war #外网应用名称 appName=hotpot-tnb-game if test "$server" != "dev" then deployPath=/opt/formal_packge/$env/hotpot-${server}-fb-overseas fi case $server in idworker) appName=hotpot-Idworker buildPath=hotpot-idworker-web/build/libs/hotpot-idworker-web.war ;; independent) appName=hotpot-Independent ;; esac #将war包解压到对应路径 rm -rf $deployPath unzip -d $deployPath $buildPath #获取Git当前版本号 LOG_PATH="/tmp/gitlog.log" git log -1 >$LOG_PATH cat_ret() { cat $LOG_PATH | egrep -n "^ {0,}commit {1,}" | awk '{print $2}' } str=`cat_ret` #发布包到服务器 output=`ssh root@192.168.1.122 "sh /data/deploy/shell/import-package.sh -r $str -n $appName -s ${deployPath}/ -u $author -a root -c 192.168.1.123"` echo $output echo "${server} deploy success!!" } if test "$server" = "all" then serverList=(dev idworker independent) for i in ${serverList[@]}; do server=${arr[$i]} deploy done else deploy fi

 

转载请注明原文地址: https://www.6miu.com/read-5038065.html

最新回复(0)