Creating a Merge Request in Gitlab triggers 2 pipelines on Jenkins

Problem Statement: I have raised a request to merge code from a feature branch to develop branch for example. Gitlab is configured with a Jenkins instance for building and deploying code. There is a Gitlab branch source plugin on Jenkins that auto configures webhooks for every project generated in Gitlab.
There are jenkins script managed in a Jenkins shared library for the different stages of the pipeline.

Now the issue here is, for every Merge request created , there are 2 build pipelines triggered, one on the source branch and one for the Merge request.
How do I ensure only 1 build pipeline is triggered for the Merge request.

Gitlab Version - GitLab Community Edition [13.6.7]

Troubleshooting so far:
I have seen that there is a solution for this issue where Gitlab CI is used,

but in my case, Jenkins is the target platform and I am not using the gitlab-ci.yml file, therefore this is not applicable
Is there any setting on Gitlab with respect to webhooks or anything else that can help resolve the issue.

Thanks

Hi @prichat

I think you need workflow rules.

1 Like