I believe this use-case applies to custom hooks too, but my use-case is modifying gitlab-shell hooks, so not exactly supported.
I want hook for all repos, so I'm calling my own class in post-receive, this works great.
However post-receive is not called for 'accept merge request' events, and I have one repo where this is only way it'll ever get commits. So I migrated my script to 'update' hook. It continues work great for 'push' events, but fails in 'merge' events. Reason it fails is, because my ruby file is requiring a gem, and this gem invariably fails with 'loaderror'.
I postulate this is because on 'push' event, ssh forks the ruby instance, so it'll see all normally installed gems. But on 'merge' event we're running inside gitlab ruby instance, which won't see it.
I tried to workaround this, by calling my ruby script via system(), but even in that case, it'll fail for LoadError on 'merge' events.
Is it possible to use your own gems in custom hooks? I believe this answer, once satisfied also applies to my unsupported use-case.
Thanks,