Gitlab CI merges without waiting for pipeline to end execution

Hi community,
Recently I am blocked on the following problem. Given the source branch of an MR, the target branch - master, and the setting to put on hold the merge until all pipelines succeed - the merge goes in straight away, while the pipeline is still running. I’m not sure if the merge takes place before the pipeline’s been triggered or after but in one case it’s violating the ‘On pipeline success’ project setting, in the other case - it’s just running at the inappropriate time.

The triggers I’m using are (under each job):
- if: “$CI_COMMIT_BRANCH == ‘master’”

How can I make it so that when I click the merge button a pipeline to be triggered which to check if the merge can happen, halting the merge self until it passes?

I read about merge results. It seems a lot like it but I’m using the free on-premise version of Gitlab, which doesn’t support it.

I haven’t worked a whole lot with rules, but if all of your jobs are meant to only run during merge requests, I might recommend looking into workflow: rules (or even one of the Gitlab rules templates).

To only run on merge requests, Gitlab provides this template with the contents:

    - if: $CI_COMMIT_TAG

You could also use the template directly with the following on the top of your .gitlab-ci.yml

  - template: 'Workflows/Branch-Pipelines.gitlab-ci.yml'


I’m not sure if this will solve your specific problem, just a suggestion.