Gerrit notes


1. 安装

Download from https://www.gerritcodereview.com/

Install guide: https://gerrit-review.googlesource.com/Documentation/install.html

2. gerrit/nginx反向代理配置

反向代理结构 http://g.cf1g.com –(301)–> https://g.cf1g.com ==(auth)==>> proxy-http://127.0.0.1:8081

2.1 gerrit.config

httpd.listenUrl: proxy-https://127.0.0.1:8081/ 配置gerrit http只接受local 8081端口请求
sshd.listenAddress: *:29418 配置gerrit ssh接受所有29418端口请求

2.2 /etc/nginx/sites-available/gerrit

auth_basic_user_file: http密码文件
ssl_certificate: ssl证书, 相对于/etc/nginx/的路径
ssl_certificate_key: ssl私钥(RSA key), 相对于/etc/nginx/的路径

2.3 /etc/nginx/sites-available/default

server:80
root: 站点的root
server:443
同样需要指定

3. 设置邮件服务器

apt-get install nginx apache2-utils fcgiwrap
apt-get install sendmail sendmail-bin
https://major.io/2007/03/27/setting-the-hostname-in-sendmail/

更详细的邮件设置: http://cfig.github.io/2015/09/22/email-notification/

4. 协同github

4.1 github插件

https://gerrit.googlesource.com/plugins/github
在github的pull request之前使用gerrit评审代码
参考步骤 https://github.com/xuanmingyi/blog/blob/master/content/GerritWithGithub.md

4.2 github登陆插件

https://github.com/davido/gerrit-oauth-provider

4.3 github oauth配置

homepage:
http://10.37.116.86:8080
auth callback URL
http://10.37.116.86:8080/oauth

5. LDAP登录

[auth]
        type = LDAP
[httpd]
        listenUrl = http://*:8080/
[ldap]
        server = ldap://XX-ldap.XX.com
        username = me@xx.com
        accountBase = OU=Workers,dc=XX,dc=com
        groupBase = OU=Workers,dc=XX,dc=com

misc

w3m https://g.cf1g.com/ssh_info
curl https://yu@g.cf1g.com/ssh_info -k -u yu
ssh -p 29418 g.cf1g.com
scp -P 29418 g.cf1g.com:hooks/commit-msg .git/hooks/
remember https password: add to .netrc
remember ssh password: .ssh/config

Add gits

ssh -p29418 name@example.com gerrit flush-caches --cache project_list

What if you got “self-signed key issue reported by git”:

workaround: 
git config --global http.sslVerify false

Reference

http://my.oschina.net/zhongl/blog/33017
http://openwares.net/linux/gerrit2\_setup.html