CircleCI 2.0删除合并的Git分支

时间:2019-02-18 12:46:40

标签: git github circleci

我想知道在Circle CI中完成合并构建后是否有删除分支的选项。从我看到的结果来看,我们仅提供了一个CIRCLE_BRANCH env变量,该变量提供了正在构建的分支的名称,但是我对正在合并的分支感兴趣,因此可以从config.yml文件内部触发分支删除。

1 个答案:

答案 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
相关问题