Gitlab 合并 "merge request" 与提交

Gitlab merge "merge request" with commit

我认为这是个愚蠢的问题,但我不明白我应该如何使用 gitlab merge request push options

我有这个场景:

git add .
git commit -m 'finish mr'
git push origin develop -o merge_request.merge_when_pipeline_succeeds
@user aborted the automatic merge because source branch was updated just now
@user added 1 commit just now

    8efdbde1 - finish mr

所以似乎推送将设置 MR 以允许在成功后合并并立即中止它,因为来自同一个推送的提交。我也尝试 quick actions 和 /merge 但结果相同。我知道有gitlabAPI,但是我不会用。有谁知道我做错了什么?

编辑:

作为接受的答案建议添加目标分支有帮助,但我还需要添加 ci.skip:

git push origin $CI_COMMIT_REF_NAME \
-o ci.skip \
-o merge_request.target="$MASTER_BRANCH_NAME" \
-o merge_request.merge_when_pipeline_succeeds \
-o merge_request.create

您可以在 gitlab-foss commit 882e798, as part of issue 63187 and MR (Merge Request) 30249 中看到针对最近的 GitLab 12.1 更新的错误消息。

merge_request.merge_when_pipeline_succeeds 选项来自 gitlab-foss MR 26752 (GitLab 11.10, April 2019), issue 43263 (release notes)。
MR 包括:

To create a new merge request, set its target branch, and set it to merge when its pipeline succeeds:

git push -u origin -o merge_request.create \
  -o merge_request.target=branch1 \
  -o merge_request.merge_when_pipeline_succeeds

Updating existing merge requests

使用现有打开的合并请求推送分支时,targetmerge_when_pipeline_succeeds 可用于更新合并请求。

所以在你的情况下,也许添加目标:

git push origin develop -o merge_request.merge_when_pipeline_succeeds \
  -o merge_request.target=master