diff --git a/util/gitutil/git_cli.go b/util/gitutil/git_cli.go index 1e497d79994c..23ff8aa4f579 100644 --- a/util/gitutil/git_cli.go +++ b/util/gitutil/git_cli.go @@ -134,6 +134,10 @@ func (cli *GitCLI) Run(ctx context.Context, args ...string) (_ []byte, err error if cli.git != "" { gitBinary = cli.git } + proxyEnvVars := [...]string{ + "HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY", "ALL_PROXY", + "http_proxy", "https_proxy", "no_proxy", "all_proxy", + } for { var cmd *exec.Cmd @@ -190,6 +194,11 @@ func (cli *GitCLI) Run(ctx context.Context, args ...string) (_ []byte, err error "HOME=/dev/null", // Disable reading from user gitconfig. "LC_ALL=C", // Ensure consistent output. } + for _, ev := range proxyEnvVars { + if v, ok := os.LookupEnv(ev); ok { + cmd.Env = append(cmd.Env, ev+"="+v) + } + } if cli.sshAuthSock != "" { cmd.Env = append(cmd.Env, "SSH_AUTH_SOCK="+cli.sshAuthSock) }