Force Launch pipeline from Merge button on MR page

I have a .yml file that suppresses pipeline lauches for ^Draft MRs, and pushes where $CI_PIPELINE_SOURCE is not equal to “merge_request_event” or “web”. Still, we need to force the pipeline to start when the Merge button is pressed. I’ve tried all likely values of $CI_PIPELINE_SOURCE and a few other things, but no luck so far. Is it possible, or how can we make it happen without giving up on the above? Thanks.

After further investigation, the Merge button click results in $CI_PIPELINE_SOURCE == “push”, which is generally one of the pipeline sources we want to suppress. But, &&'ing it with $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH appears to get the pipeline control we are looking for.

The Merge button merges a source branch into the target branch creating a Commit in the target branch which triggeres a pipeline with source “push” in the target branch. At this point it has nothing to do with the MR or merge request pipelines anymore. It is pipeline like if someone would push to branch directly.

Depending on your use-case, if you need to run it on default branch having a rule
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
is sufficient. Just keep in mind such job will be triggered also if someone pushes to default branch.