GitLab 6.9.0 - " hook拒绝更新refs / heads / master"

时间:2014-05-26 10:16:13

标签: git hook push gitlab

最后几天我读了很多同样问题的帖子。有些人有解决方案,但对我没有任何作用。

通过更新脚本更新到6.9.0后,当我推送时,我得到了

POST git-receive-pack (896 bytes)
remote: /usr/local/lib/ruby/2.0.0/net/protocol.rb:158:in `rescue in rbuf_fill': Net::ReadTimeout (Net::ReadTimeout)[K
remote:     from /usr/local/lib/ruby/2.0.0/net/protocol.rb:152:in `rbuf_fill'[K
remote:     from /usr/local/lib/ruby/2.0.0/net/protocol.rb:134:in `readuntil'[K
remote:     from /usr/local/lib/ruby/2.0.0/net/protocol.rb:144:in `readline'[K
remote:     from /usr/local/lib/ruby/2.0.0/net/http/response.rb:39:in `read_status_line'[K
remote:     from /usr/local/lib/ruby/2.0.0/net/http/response.rb:28:in `read_new'[K
remote:     from /usr/local/lib/ruby/2.0.0/net/http.rb:1406:in `block in transport_request'[K
remote:     from /usr/local/lib/ruby/2.0.0/net/http.rb:1403:in `catch'[K
remote:     from /usr/local/lib/ruby/2.0.0/net/http.rb:1403:in `transport_request'[K
remote:     from /usr/local/lib/ruby/2.0.0/net/http.rb:1376:in `request'[K
remote:     from /home/git/gitlab-shell/lib/gitlab_net.rb:76:in `block in get'[K
remote:     from /usr/local/lib/ruby/2.0.0/net/http.rb:852:in `start'[K
remote:     from /home/git/gitlab-shell/lib/gitlab_net.rb:76:in `get'[K
remote:     from /home/git/gitlab-shell/lib/gitlab_net.rb:31:in `allowed?'[K
remote:     from /home/git/gitlab-shell/lib/gitlab_update.rb:39:in `exec'[K
remote:     from hooks/update:14:in `<main>'[K
remote: error: hook declined to update refs/heads/master[K
Pushing to http://xyz/xyz/test.git
To http://xyz/xyz/test.git
 ! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 'http://xyz/xyz/test.git'

Repo是新创建的。它是空的,我尝试推送新文件。此问题也发生在现有的Repos上。

这里有一些Server-Infos:

root@v22014011205216285:/home/git/gitlab# sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production

System information
System:         Debian 7.5
Current User:   git
Using RVM:      no
Ruby Version:   2.0.0p247
Gem Version:    2.0.3
Bundler Version:1.5.1
Rake Version:   10.3.1
Sidekiq Version:2.17.0

GitLab information
Version:        6.9.0
Revision:       f0a32c6
Directory:      /home/git/gitlab
DB Adapter:     mysql2
URL:            http://xyz
HTTP Clone URL: http://xyz/some-project.git
SSH Clone URL:  git@xyz:some-project.git
Using LDAP:     no
Using Omniauth: no

GitLab Shell
Version:        1.9.4
Repositories:   /home/git/repositories/
Hooks:          /home/git/gitlab-shell/hooks/
Git:            /usr/bin/git

root@v22014011205216285:/home/git/gitlab# sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
Checking Environment ...

Git configured for git user? ... yes

Checking Environment ... Finished

Checking GitLab Shell ...

GitLab Shell version >= 1.9.4 ? ... OK (1.9.4)
Repo base directory exists? ... yes
Repo base directory is a symlink? ... no
Repo base owned by git:git? ... yes
Repo base access is drwxrws---? ... yes
Satellites access is drwxr-x---? ... yes
update hook up-to-date? ... yes
update hooks in repos are links: ...
xyz / 1 ... ok
[...]
xyz / 2 ... ok
Running /home/git/gitlab-shell/bin/check
Check GitLab API access: OK
Check directories and files:
        /home/git/repositories: OK
        /home/git/.ssh/authorized_keys: OK
Test redis-cli executable: redis-cli 2.4.14
Send ping to redis server: PONG
gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Sidekiq ...

Running? ... yes
Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking LDAP ...

LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab ...

Database config exists? ... yes
Database is SQLite ... no
All migrations up? ... yes
Database contains orphaned UsersGroups? ... no
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Init script exists? ... yes
Init script up-to-date? ... yes
projects have namespace: ...
xyz / 1 ... yes
[...]
xyz / 2 ... yes
Oliver Lippert / test ... yes
Projects have satellites? ...
xyz / 1 ... yes
[...]
xyz / 2 ... yes
Redis version >= 2.0.0? ... yes
Your git bin path is "/usr/bin/git"
Git version >= 1.7.10 ? ... yes (1.7.10)

Checking GitLab ... Finished

update-hook是标准gitlab-shell update-script

的符号链接
#!/usr/local/bin/ruby

# This file was placed here by GitLab. It makes sure that your pushed commits
# will be processed properly.
# You can add your own hooks to this file, but be careful when updating gitlab-shell!

refname = ARGV[0]
key_id  = ENV['GL_ID']
repo_path = Dir.pwd
#repo_path = `pwd`

require_relative '../lib/gitlab_update'

GitlabUpdate.new(repo_path, key_id, refname).exec

(我想我做了一两件小事,但问题出在我的小改动之前和之后)。

有人可以帮我分析和解决这个问题吗?

感谢您的反馈。

PS:几天前我在这里开了一个问题:https://github.com/gitlabhq/gitlabhq/issues/6978

我还有第二个GitLab-Instance更新到6.9.0,它运行没有任何问题?

5 个答案:

答案 0 :(得分:3)

我不知道这是否可以帮助某人,但我找到了解决这个“错误”的解决方案。

在您的存储库文件夹/home/git/repositories/user/project_name.git/hooks/update中,只需替换第一行:

#!/usr/local/bin/ruby

由此:

#!/usr/bin/env ruby

这救了我,所以我希望它可以帮助别人。

答案 1 :(得分:1)

对我来说问题是我配置了独角兽来启动一个工作流程。

Unicorn启动GET-Request以确定是否允许当前推送用户推送。没有第二个工人,这个请求永远不会被回答。

答案 2 :(得分:1)

我遇到同样的错误,我的解决方案暂时禁用更新文件,推完后启用它

答案 3 :(得分:0)

尝试设置PermitUserEnvironment值

答案 4 :(得分:0)

以下步骤有助于解决问题

  1. 使用git remote rm origin
  2. 删除原点
  3. 使用git remote add origin https://github.com/<repo_name>
  4. 添加原点
  5. 使用git remote -v
  6. 检查是否已设置遥控器
  7. 再次尝试git push origin <branch>