Gitlab CI merge request not building merged branch

Gitlab CI integrates very nicely with the merge request interface in Gitlab. However, I’ve noticed that when a merge request is made, Gitlab CI only builds the branch that’s being merged in, and not the result of the merge. What this means is that the merge could potentially break the master branch, and the testing would not be aware of it.

This doesn’t seem very useful. Is there an option to get Gitlab CI to merge master into the branch before it builds? I was considering adding the git merge command in the build config yml file, but I think that would create a problem when building the master branch itself (without a merge), as it would be asking the master branch to merge with itself. Any ideas?

Thanks in advance!

Exactly what you describe is what I am missing too. We now migrating from Jenkins to GitLab CI. And this feature is missing or I can not find. In Jenkins this option is called Merge before build.

I also open a thread here

Hi @nimski! That actually is a feature in GitLab now, you can enabled Pipelines for Merged Results by configuring your pipelines. You can also read more about merge trains about lining up merges so that you can ensure the main branch is always “green”

1 Like