我想知道在Circle CI中完成合并构建后是否有删除分支的选项。从我看到的结果来看,我们仅提供了一个CIRCLE_BRANCH env变量,该变量提供了正在构建的分支的名称,但是我对正在合并的分支感兴趣,因此可以从config.yml文件内部触发分支删除。
答案 0 :(得分:0)
我设法找到了解决方案:
MESSAGE="$(git show -s --format=%s $1 | grep 'Merge pull request')"
if [ -z "${MESSAGE}" ]; then
echo 'Not a merge commit message'
exit 1
fi
BRANCH="$(git show -s --format=%s $1 | grep -oE '[^ ]+$')"
# extract actual branch name that gets deleted
BRANCH="$(echo $BRANCH | sed -e 's/PaymentFusion\///g')"
# command used to remote delete branch that was merged
git push origin --delete $BRANCH