jenkins限制未merge master分支无法部署

主要是通过shell执行git branch –no-merged来判断是否有未合并master代码,如下${qa_branch}是选择的部署分支:

git checkout master
git checkout ${qa_branch}
for branch in `git branch –no-merged`
do
if [ “$branch” == “master” ];then

echo -e “The branch has not merged master, please merge first.”
exit 1
fi
done

以支付收单为例:

一、配置变量参数

二、在maven编译前执行shell脚本

三、部署分支,检测是否合并master,未合并时直接退出构建