1

I have recently stumbled upon a use-case where I want to make MRs into my master branch automatically. Every one of those MRs would edit a documentation file which does not in any way affect business flows or local / remote app config. I unfortunately need to make an MR to trigger a webhook that talks to a different repo, instead of just committing the documentation file to master directly.

The closest I have found to "automatically" is the merge_request.merge_when_pipeline_succeeds push option which is available since Git 2.10. I was wondering if there is a way for me to even skip the pipeline stage as, in my case, it is useless and just wastes time. I suspect that this is not supported out of an abundance of caution, but it couldn't hurt to ask.

4
  • 1
    So merge them. What question do you want to ask? Here is the API docs.gitlab.com/ee/api/… . Anyway, I do not understand why make a merge request that auto merges, just push the edits to master.
    – KamilCuk
    Commented Dec 14, 2023 at 16:47
  • I agree with @KamilCuk. If you are trying to automatically create an MR and then automatically complete it, then perhaps you can simply checkout master, make your commit, then push it, fast enough that you don't need to merge. You may need to adjust permissions so that the user that pushes the commit can bypass branch protection, but perhaps doing that is simpler than automating an MR.
    – TTT
    Commented Dec 14, 2023 at 18:48
  • 1
    I failed to clarify that I need to make an MR into master instead of directly pushing to it, to trigger a webhook that occurs on Merge Request events. I edited the original post to mention this, my mistake.
    – Jason
    Commented Jan 3 at 11:31
  • Fair enough. Good edit. Another thing is unclear to me: the title suggests you wish to automatically complete an existing MR (I assume if some condition is met...), but the first sentence suggests you want to automatically create an MR (I assume triggered by some process). Maybe you wish to do both? For example, perhaps you start a process which creates a branch, makes a doc change and commits it while on that branch, pushes the branch, creates an MR, then completes the MR?
    – TTT
    Commented Jan 3 at 17:18

1 Answer 1

0

With GitLab 17.4 (September 2024), if you can create a MR with checks, then you can set your MR to "Auto-merge":

Auto-merge when all checks pass

Merge requests have many required checks that must pass before they are mergeable. These checks can include approvals, unresolved threads, pipelines, and other items that need to be satisfied. When you’re responsible for merging code, it can be hard to keep track of all of these events, and know when to come back and check to see if a merge request can be merged.

GitLab now supports Auto-merge for all checks in merge requests. Auto-merge enables any user who is eligible to merge to set a merge request to Auto-merge, even before all the required checks have passed. As the merge request continues through its lifecycle, the merge request automagically merges after the last failing check passes.

https://docs.gitlab.com/ee/user/project/merge_requests/img/auto_merge_ready_v16_0.png

We’re really excited about this improvement to accelerate your merge request workflows. You can leave feedback about this feature in issue 438395.

See Documentation, Issue and Epic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.