I believe it's stupid question but I don't understand how should I use gitlab merge request push options
I have this scenario:
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
So it seems that the push will set MR to allow merge after succeed and immediately abort it because of commit from same push. I also tried quick actions with /merge but same result. I know there is gitlab API, but I can't use it. Does anyone know what I am doing wrong?
EDIT:
as accepted answer suggested adding target branch helped, but I also needed to add 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
You can see that error message updated in gitlab-foss
commit 882e798, as part of issue 63187 and MR (Merge Request) 30249 for recent GitLab 12.1.
That merge_request.merge_when_pipeline_succeeds
option comes from gitlab-foss MR 26752 (GitLab 11.10, April 2019), issue 43263 (release notes).
The MR includes:
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
When pushing branches with an existing open merge request, target
and merge_when_pipeline_succeeds
can be used to update the merge request.
So in your case, maybe add the target:
git push origin develop -o merge_request.merge_when_pipeline_succeeds \
-o merge_request.target=master