1 Star 0 Fork 2

shendingjun/gitlab-auto-merge

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
acceptMR.sh 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
林万程 提交于 2021-02-07 19:52 . 1.0
#!/usr/bin/env bash
set -e
# https://docs.gitlab.com/ee/api/merge_requests.html#list-project-merge-requests
echo "
curl \"${GITLAB_API_URL}/${CI_PROJECT_ID}/merge_requests?state=opened&source_branch=${CI_COMMIT_REF_NAME}\"
--header \"PRIVATE-TOKEN:${GITLAB_PRIVATE_TOKEN}\"
--silent
"
listMR=`curl "${GITLAB_API_URL}/${CI_PROJECT_ID}/merge_requests?state=opened&source_branch=${CI_COMMIT_REF_NAME}" \
--header "PRIVATE-TOKEN:${GITLAB_PRIVATE_TOKEN}" \
--silent`
echo "$listMR
"
listMR_iid=$(echo $listMR | cut -d ':' -f 3 | cut -d ',' -f 1)
if [[ $listMR_iid != *[0-9] ]]; then
exit 1
fi
# https://docs.gitlab.com/ee/api/merge_requests.html#accept-mr
echo "
curl -X PUT \"${GITLAB_API_URL}/${CI_PROJECT_ID}/merge_requests/$listMR_iid/merge\"
--header \"PRIVATE-TOKEN: ******\"
--silent
"
acceptMR=`curl -X PUT "${GITLAB_API_URL}/${CI_PROJECT_ID}/merge_requests/$listMR_iid/merge" \
--header "PRIVATE-TOKEN: ${GITLAB_PRIVATE_TOKEN}" \
--silent`
echo "$acceptMR
"
acceptMR_iid=$(echo $acceptMR | cut -d ':' -f 3 | cut -d ',' -f 1)
if [[ $acceptMR_iid != *[0-9] ]]; then
exit 1
fi
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/shendingjun/gitlab-auto-merge.git
git@gitee.com:shendingjun/gitlab-auto-merge.git
shendingjun
gitlab-auto-merge
gitlab-auto-merge
main

搜索帮助