GrahamL GrahamL -3 years ago 93
Git Question

gitlab implementing a a hook when merge is requested

I want to run a script when a merge request is generated from gitlab
I 'think' I have 3 alternatives
git hook
gitlab webhook
gitlab trigger

I would appreciate some advice from anyone who has done this before and what would be the best method


Answer Source

Git hooks are a native Git feature, git does not have a concept of merge requests - they are a feature of GitLab and competitor's platforms. As such a git hook will not meet your needs in this case.

GitLab webhooks are the solution you are looking for, as they can be triggered 'upon a merge request' being opened etc, see docs. They work by invoking a HTTP(S) endpoint, so if your script is set to run upon a request to this endpoint, or via some external build process (e.g. Jenkins) then these should meet your needs.

Triggers are for 'triggering' the rebuild of your project via GitLab (CI) (re-running a gitlab pipeline or external build), see docs. So they might meet your needs if the script to be run can be setup with gitlab CI or an external build process that can be integrated into GitLab.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download