As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit cc760049 authored by Valery Sizov's avatar Valery Sizov
Browse files

Fix: Allow Git Hooks to be executed in another Ruby env when committing from the web UI

parent c6d8af59
No related branches found
No related tags found
No related merge requests found
v3.5.1
- Clear environment variables before running hooks
v3.5.0
- Add option to recover 2FA via SSH
Loading
Loading
require 'open3'
require 'bundler'
class GitlabCustomHook
def pre_receive(changes, repo_path)
Loading
Loading
@@ -11,7 +12,7 @@ class GitlabCustomHook
def post_receive(changes, repo_path)
hook = hook_file('post-receive', repo_path)
return true if hook.nil?
call_receive_hook(hook, changes)
end
Loading
Loading
@@ -19,7 +20,9 @@ class GitlabCustomHook
hook = hook_file('update', repo_path)
return true if hook.nil?
system(hook, ref_name, old_value, new_value)
Bundler.with_clean_env do
system(hook, ref_name, old_value, new_value)
end
end
private
Loading
Loading
@@ -28,7 +31,13 @@ class GitlabCustomHook
# Prepare the hook subprocess. Attach a pipe to its stdin, and merge
# both its stdout and stderr into our own stdout.
stdin_reader, stdin_writer = IO.pipe
hook_pid = spawn(hook, in: stdin_reader, err: :out)
hook_pid = nil
Bundler.with_clean_env do
hook_pid = spawn(hook, in: stdin_reader, err: :out)
end
stdin_reader.close
# Submit changes to the hook via its stdin.
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment