Allow Git Hooks to be executed in another Ruby env when committing from the web UI
Zendesk issue: https://gitlab.zendesk.com/agent/tickets/33327
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/git/hook.rb#L46 is responsible for executing gitlab-shell
hooks when a commit is made from the web UI. This works fine in 99% of the cases, especially when the script either 1) doesn't use Ruby or 2) uses Ruby but doesn't rely on other gems.
In this customer's case, the custom pre-receive hook relies on Puppet. The shebang in /usr/bin/puppet
is #!/usr/bin/ruby
explicitly. Yet, the script apparently tries to execute within the context of the GitLab environment. This produces the error /opt/gitlab/embedded/service/gitlab-rails/Gemfile:17:in
eval_gemfile': (Bundler::Dsl::DSLError)presumably because
puppet` is not in the Gemfile.
Is it possible to tell Open3
or in some other way, allow these hooks to execute 100% independent of the GitLab embedded environment? This used to work fine because the web editor committed using satellites - which would invoke the custom hook in the context of gitlab-shell instead of the embedded environment.
cc/ @vsizov @dzaporozhets