About Auto-merge feature

Hi, i’m experieced with Git but new to GitLab. I’m learning on Gitlab.com and have question about auto-merge feature. I want the workflow to be: received a merge request from ‘feature’ branch to ‘main’ branch - run pipeline that build the source code, test it but not push it to remote ‘main’ branch. When i tried on web GUI gitlab.com by click the Merge button, the pipeline is triggered and source code is merged automatically when it succedded.
As stated at Auto-merge | GitLab, I should have the button ‘Set to auto-merge’ but I dont have it at all.

Just want to clarify this feature or if there is any solution for my desired workflow. Thanks in advance!

Auto-merge will only show the button set to auto-merge when the pipeline is still executing. After the pipeline has finished, like shown in your screenshot, it will default to merge.

The benefit of auto-merge is that you do not need to wait until the pipeline finishes, and can close the browser tab, and focus on other tasks. When the pipeline succeeds, it will trigger the MR merge automatically.

You can also add more safeguards for code reviews in the MR, i.e. required approvals from Codeowners. That ensures that even if the pipeline succeeds, a reviewer will have to step in and approve, before the MR can be merged to main.

Thanks for your answer! I now understand the auto-merge feature but still stuck on how to deal with my desired workflow. When we create new MR, a CI/CD pipeline will run on ‘feature’ branch which I intend to run some unit test. When maintainer approve the MR and and click button Merge, a pipeline is run on branch ‘main’ and if this pipeline succeed, the code is actually merged on remote. What I want in my project when devs create new merge request is:

  • Run pipeline on their feature branch (same as default gitlab behavior)

  • Run pipeline on main branch but if the pipeline succeed, not merge the code on remote. I just want to run pipeline to build a binary file, take that binary file to a test on hardware devices to make sure the merge version works properly. After the test on hardware devices succeed, make the real merge action.