(Jenkins/GitLab) Webhook triggered when a user is assigned

In GitLab, I have made it so that when a Merge Request is created, it triggers Jenkins which builds the source branch.

(This is how I did it: In GitLab, I’ve added a webhook on a Merge Request, and in Jenkins, I’ve configured it to accept merge requests)

Problem is, if there’s an Open Merge Request, and after a while someone assigns a user to that Merge Request, that will trigger the webhook and it will build the Jenkins job again, even though it’s not necessary.

Is it possible to not have the Jenkins job triggered when a user is assigned to the GitLab Merge Request? (I couldn’t find anything online and in Jenkins, it looks exactly the same in terms of the build and environment variables)

Thanks ahead!

Hi :wave: ,

Could you write a conditional stage to the pipeline that deals with the webhook?
The documentation says:

The field object_attributes.oldrev is only available when there are actual code changes, like:

So… You could maybe start the other stages when this field is not empty.
My $0.02/

1 Like

Thanks for the response!

That seems like it may work! My Jenkins job is Freestyle though, is it still possible to do? Also, how would I go about it, and where do I have to implement this change? I’m a bit unsure about where to handle the payload GitLab sends.

1 Like

resolved: https://i.imgur.com/cY9cyci.png

1 Like

Thanks a lot for your feeback.