报错git operation was rejected by pre-receive hook
无意间找到一个检测gitlab的是否完整的命令
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
GitLab Shell version >= 2.7.2 ? ... OK (2.7.2) 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 hooks directories in repos are links: ... Administrator / tgrambaseline1.0 ... repository is empty Administrator / testing ... ok Running /home/git/gitlab-shell/bin/check Check GitLab API access: FAILED. code: 404 gitlab-shell self-check failed Try fixing it: Make sure GitLab is running; Check the gitlab-shell configuration file: sudo -u git -H editor /home/git/gitlab-shell/config.yml Please fix the error above and rerun the checks.
从日志可以看出 提示我 gitlab-shell有问题 让我改 /home/git/gitlab-shell/config.yml 文件
先查看一下这个文件
sudo -u git -H vi /home/git/gitlab-shell/config.yml
user: git gitlab_url: http://xxx.xxx.xxx.xx/ http_settings: self_signed_cert: false repos_path: "/home/git/repositories/" auth_file: "/home/git/.ssh/authorized_keys" redis: bin: "/usr/bin/redis-cli" namespace: resque:gitlab socket: "/var/run/redis/redis.sock" log_level: INFO audit_usernames: false
GitLab设置IP或者域名有两个配置文件:
1、GitLab的:/home/git/gitlab/config/gitlab.yml
2、GitLab-Shell的:/home/git/gitlab-shell/config.yml
把两个配置文件的IP或者域名修正过来即可。在GitLab-Shell的配置文件中,如果域名带端口号,也要把端口号写上。例如我的是gitlab_url: "http://gitlab.xxxx.xxxx.com:8088/"
加上端口号就好了。