Skip to content

hooks are not installed #676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tostr7191 opened this issue May 29, 2017 · 5 comments
Closed

hooks are not installed #676

tostr7191 opened this issue May 29, 2017 · 5 comments
Assignees
Labels

Comments

@tostr7191
Copy link

tostr7191 commented May 29, 2017

Hi

Just installed gitolite and redmine_git_hosting on our redmine 3.3. The hooks can't be installed for some reason. Log shows this:

==> log/git_hosting.log <==
2017-05-29 14:38:51 +0000 [INFO] Hook 'redmine_gitolite.rb' does not exist, installing it ...
2017-05-29 14:38:51 +0000 [INFO] Installing hook '/home/redmine/redmine-3.3.3/plugins/redmine_git_hosting/contrib/hooks/post-receive/redmine_gitolite.rb' in '/home/git/local
/hooks/common/post-receive'
2017-05-29 14:38:51 +0000 [ERROR] Non-zero exit code pid 29061 exit 1 for `sudo -n -u git -i sh`
2017-05-29 14:38:51 +0000 [INFO] Hook 'mail_notifications.py' does not exist, installing it ...
2017-05-29 14:38:51 +0000 [INFO] Installing hook '/home/redmine/redmine-3.3.3/plugins/redmine_git_hosting/contrib/hooks/post-receive/mail_notifications.py' in '/home/git/local
/hooks/common/post-receive.d/mail_notifications'
2017-05-29 14:38:51 +0000 [ERROR] Non-zero exit code pid 29130 exit 1 for `sudo -n -u git -i sh`
2017-05-29 14:38:51 +0000 [INFO] Hook 'git_hosting_config.rb' does not exist, installing it ...
2017-05-29 14:38:51 +0000 [INFO] Installing hook '/home/redmine/redmine-3.3.3/plugins/redmine_git_hosting/contrib/hooks/post-receive/lib/git_hosting_config.rb' in '/home/git/local
/hooks/common/lib/git_hosting/config.rb'
2017-05-29 14:38:51 +0000 [ERROR] Non-zero exit code pid 29199 exit 1 for `sudo -n -u git -i sh`
2017-05-29 14:38:51 +0000 [INFO] Hook 'git_hosting_custom_hook.rb' does not exist, installing it ...
2017-05-29 14:38:51 +0000 [INFO] Installing hook '/home/redmine/redmine-3.3.3/plugins/redmine_git_hosting/contrib/hooks/post-receive/lib/git_hosting_custom_hook.rb' in '/home/git/local
/hooks/common/lib/git_hosting/custom_hook.rb'
2017-05-29 14:38:51 +0000 [ERROR] Non-zero exit code pid 29268 exit 1 for `sudo -n -u git -i sh`
2017-05-29 14:38:52 +0000 [INFO] Hook 'git_hosting_http_helper.rb' does not exist, installing it ...
2017-05-29 14:38:52 +0000 [INFO] Installing hook '/home/redmine/redmine-3.3.3/plugins/redmine_git_hosting/contrib/hooks/post-receive/lib/git_hosting_http_helper.rb' in '/home/git/local
/hooks/common/lib/git_hosting/http_helper.rb'
2017-05-29 14:38:52 +0000 [ERROR] Non-zero exit code pid 29337 exit 1 for `sudo -n -u git -i sh`
2017-05-29 14:38:52 +0000 [INFO] Hook 'git_hosting_hook_logger.rb' does not exist, installing it ...
2017-05-29 14:38:52 +0000 [INFO] Installing hook '/home/redmine/redmine-3.3.3/plugins/redmine_git_hosting/contrib/hooks/post-receive/lib/git_hosting_hook_logger.rb' in '/home/git/local
/hooks/common/lib/git_hosting/hook_logger.rb'
2017-05-29 14:38:52 +0000 [ERROR] Non-zero exit code pid 29406 exit 1 for `sudo -n -u git -i sh`
2017-05-29 14:38:52 +0000 [INFO] Hook 'git_hosting_post_receive.rb' does not exist, installing it ...
2017-05-29 14:38:52 +0000 [INFO] Installing hook '/home/redmine/redmine-3.3.3/plugins/redmine_git_hosting/contrib/hooks/post-receive/lib/git_hosting_post_receive.rb' in '/home/git/local
/hooks/common/lib/git_hosting/post_receive.rb'
2017-05-29 14:38:52 +0000 [ERROR] Non-zero exit code pid 29475 exit 1 for `sudo -n -u git -i sh`
2017-05-29 14:38:52 +0000 [INFO] Hook 'git_multimail.py' does not exist, installing it ...
2017-05-29 14:38:52 +0000 [INFO] Installing hook '/home/redmine/redmine-3.3.3/plugins/redmine_git_hosting/contrib/hooks/post-receive/lib/git_multimail.py' in '/home/git/local
/hooks/common/post-receive.d/git_multimail.py'
2017-05-29 14:38:52 +0000 [ERROR] Non-zero exit code pid 29544 exit 1 for `sudo -n -u git -i sh`
2017-05-29 14:38:52 +0000 [INFO] Set Git global parameter : redminegitolite.redmineurl (https://redmine.doc.coach/githooks/post-receive/redmine)
2017-05-29 14:38:52 +0000 [INFO] Set Git global parameter : redminegitolite.debugmode (false)
2017-05-29 14:38:53 +0000 [INFO] Set Git global parameter : redminegitolite.asyncmode (true)
2017-05-29 14:38:53 +0000 [INFO] Set Git global parameter : multimailhook.mailer (smtp)
2017-05-29 14:38:53 +0000 [INFO] Set Git global parameter : multimailhook.environment (gitolite)
2017-05-29 14:38:53 +0000 [INFO] Set Git global parameter : multimailhook.smtpauth (false)
2017-05-29 14:38:53 +0000 [INFO] Set Git global parameter : multimailhook.smtpserver (localhost)
2017-05-29 14:38:53 +0000 [INFO] Set Git global parameter : multimailhook.smtpport (25)

This is the versions we're running:

Environment:
  Redmine version                3.3.3.stable
  Ruby version                   2.3.1-p112 (2016-04-26) [x86_64-linux]
  Rails version                  4.2.7.1
  Environment                    production
  Database adapter               PostgreSQL
SCM:
  Subversion                     1.7.14
  Git                            2.13.0
  Filesystem                     
  Xitolite                       2.13.0
Redmine plugins:
  redmine_agile                  1.4.2
  redmine_bootstrap_kit          0.2.5
  redmine_git_hosting            1.2.2
  redmine_slack                  0.2

gitolite:

hello redmine_gitolite_admin_id_rsa, this is git@rhododendron running gitolite3 v3.6.6-11-gd77bf42 on git 2.13.0

sudo works as expected (I can sudo -iu git as redmine and it works without password). I can create repos and clone them, but pushes are not registered by redmine.

screen shot 2017-05-29 at 17 11 50

this is what happens when I click on Install hooks

Thanks in advance for any help! It is appreciated.

@tostr7191
Copy link
Author

Setting the log level to DEBUG I found this:

2017-05-29 16:37:14 +0000 [DEBUG] Getting Gitolite version...
2017-05-29 16:37:14 +0000 [DEBUG] Non-zero exit code pid 18139 exit 1 for `sudo -n -u git -i sh`
2017-05-29 16:37:14 +0000 [ERROR] Non-zero exit code pid 18139 exit 1 for `sudo -n -u git -i sh`
2017-05-29 16:37:14 +0000 [DEBUG] Getting Gitolite version...
2017-05-29 16:37:14 +0000 [DEBUG] Getting Gitolite version...
2017-05-29 16:37:14 +0000 [INFO] Hook 'git_hosting_post_receive.rb' does not exist, installing it ...
2017-05-29 16:37:14 +0000 [DEBUG] Getting Gitolite version...
2017-05-29 16:37:15 +0000 [DEBUG] Getting Gitolite version...
2017-05-29 16:37:15 +0000 [INFO] Installing hook '/home/redmine/redmine-3.3.3/plugins/redmine_git_hosting/contrib/hooks/post-receive/lib/git_hosting_post_receive.rb' in '/home/git/local
/hooks/common/lib/git_hosting/post_receive.rb'
2017-05-29 16:37:15 +0000 [DEBUG] Getting Gitolite version...
2017-05-29 16:37:15 +0000 [DEBUG] Non-zero exit code pid 18208 exit 1 for `sudo -n -u git -i sh`
2017-05-29 16:37:15 +0000 [ERROR] Non-zero exit code pid 18208 exit 1 for `sudo -n -u git -i sh`
2017-05-29 16:37:15 +0000 [DEBUG] Getting Gitolite version...
2017-05-29 16:37:15 +0000 [DEBUG] Getting Gitolite version...
2017-05-29 16:37:15 +0000 [INFO] Hook 'git_multimail.py' does not exist, installing it ...
2017-05-29 16:37:15 +0000 [DEBUG] Getting Gitolite version...
2017-05-29 16:37:15 +0000 [DEBUG] Getting Gitolite version...
2017-05-29 16:37:15 +0000 [INFO] Installing hook '/home/redmine/redmine-3.3.3/plugins/redmine_git_hosting/contrib/hooks/post-receive/lib/git_multimail.py' in '/home/git/local
/hooks/common/post-receive.d/git_multimail.py'
2017-05-29 16:37:15 +0000 [DEBUG] Getting Gitolite version...
2017-05-29 16:37:15 +0000 [DEBUG] Non-zero exit code pid 18277 exit 1 for `sudo -n -u git -i sh`
2017-05-29 16:37:15 +0000 [ERROR] Non-zero exit code pid 18277 exit 1 for `sudo -n -u git -i sh`
2017-05-29 16:37:15 +0000 [DEBUG] Getting Gitolite version...

Might there be a problem with it finding the gitolite version? It does not say success or failure.

@tostr7191
Copy link
Author

tostr7191 commented May 29, 2017

Outputting stderr and some other stuff yields the following:

command: sudo
args: ["-n", "-u", "git", "-i", "sh"]
opts: {:stdin_data=>"cat <<\\EOF >/home/git/local\n/hooks/common/post-receive \n#!/usr/bin/env ruby\n\n#
This file was placed here by Redmine Git Hosting. It makes sure that your pushed commits\n# will be proce
ssed properly.\n\nrefs = ARGF.read\nrepo_path = Dir.pwd\n\nrequire_relative 'lib/git_hosting/http_helper'
\nrequire_relative 'lib/git_hosting/hook_logger'\nrequire_relative 'lib/git_hosting/config'\nrequire_rela
tive 'lib/git_hosting/post_receive'\nrequire_relative 'lib/git_hosting/custom_hook'\n\nif GitHosting::Pos
tReceive.new(repo_path, refs).exec && GitHosting::CustomHook.new(repo_path, refs).exec\n  exit 0\nelse\n
 exit 1\nend\nEOF", :binmode=>true}
stderr: sh: line 1: /home/git/local: Is a directory

It seems to me that the mistake might happen here? The \n in the file looks kinda off.

opts: {:stdin_data=>"cat <<\\EOF >/home/git/local\n/hooks/common/post-receive \n#!/usr/bin/env ruby\n\n#
[...]

@tostr7191
Copy link
Author

tostr7191 commented May 29, 2017

I managed to get it to work (in a hacky way). I changed the capture method in lib/redmine_git_hosting/utils/exec.rb to look like this:

diff --git a/lib/redmine_git_hosting/utils/exec.rb b/lib/redmine_git_hosting/utils/exec.rb
index e5193f4f..c0881576 100644
--- a/lib/redmine_git_hosting/utils/exec.rb
+++ b/lib/redmine_git_hosting/utils/exec.rb
@@ -12,6 +12,9 @@ module RedmineGitHosting
       # we rethrow a +GitoliteCommandException+ with a meaningful error message.
       def capture(command, args = [], opts = {}, &block)
         merge_output = opts.delete(:merge_output) { false }
+        unless opts[:stdin_data].nil?
+         opts[:stdin_data].sub!("local\n/hooks", "local/hooks")
+       end
         stdout, stderr, code = execute(command, args, opts, &block)
         if code != 0
           error_msg = "Non-zero exit code #{code} for `#{command} #{args.join(" ")}`"

Now it works as expected. But there seems to have been a bug introduced in the generation of stdin_data. Someone familiar with the codebase could probably figure this out quickly, I did not have any luck :)

I will still leave this open for the moment, curios to see if this is some weirdness on my box or a general problem.

@vanch
Copy link

vanch commented May 31, 2017

Here's the solution #646

@tostr7191
Copy link
Author

Ah thanks for the heads up! Closing. (Aww! Plan9 Bunny goes to space!)

@n-rodriguez n-rodriguez self-assigned this Jun 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants