Jenkins+Git-Flow打包分支切换脚本

切换到最新的release or hotfix分支

type=$1
git stash
git checkout master
git pull
git branch | grep -v "master" | xargs git branch -D
selectedBranch=`git branch -a|grep -P ${type}'/\d+\.\d+\.\d+.*' -o|sort -rV|head -n 1`
echo 'selected branch:'${selectedBranch}
git checkout -b ${selectedBranch}

切换到最新版本的TAG

git stash
git checkout master
git pull
git branch | grep -v "master" | xargs git branch -D
selectedTag=`git tag|grep -P '\d+\.\d+\.\d+.*' -o|sort -rV|head -n 1`
echo 'selected tag:'${selectedTag}
git checkout -b ${selectedTag}

你可能感兴趣的:(Jenkins+Git-Flow打包分支切换脚本)