Our team is developing a Jenkins job using which we can create Merge/Pull request when we are merge dev branch to release branch in our repo. This job will do this task for 32 repos at once as all repos have same branch names. Version control is gitlab.
Now, I am using following command in Jenkins Build Step > Execute Shell to create merge request.
git push -v --push-option='merge_request.create' origin ${SourceBranch}:${TargetBranch}
Now Instead of creating Merge request, it is directly merging the two branches.
Please help me to solve this problem.
Thanks in advance.
origin ${SourceBranch}:${TargetBranch}
This will push your source branch to the remote target branch, which is not what you want.
To get the behavior you want (creating an MR from source to target) push to the source branch and use the merge_request.target
option to specify the target branch for the MR.
git push -v \
-o merge_request.create \
-o merge_request.target="${TargetBranch}" \
origin "${SourceBranch}"
This will push to the source branch and create an MR from the source branch to the target branch.