增加nginx配置
server {
listen 80;
server_name XXXX.XXXXX.com; // Gerrit主机所在的域名
allow all;
deny all;
auth_basic "Welcomme to Gerrit Code Review Site!";
auth_basic_user_file /var/gerrit/gerrit.password;
location / {
proxy_pass http://localhost:8080;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
添加用户信息
htpasswd -c /var/gerrit/gerrit.password admin
htpasswd /var/gerrit/gerrit.password jijun.xie
安装gerrit
java -jar gerrit-2.15.3.war init -d ~/gerrit
gerrit config配置
root@zabbixserver:~/gerrit/etc# cat gerrit.config
[gerrit]
basePath = git
serverId = 4e1db49b-5b0b-4332-8ff7-90e44a3bdc8c
canonicalWebUrl = http://XXXX.XXXXX.com // 代码review发送邮件中包含连接的前缀
[database]
type = h2
database = /root/gerrit/db/ReviewDB
[noteDb "changes"]
disableReviewDb = true
primaryStorage = note db
read = true
sequence = true
write = true
[index]
type = LUCENE
[auth]
type = HTTP
[receive]
enableSignedPush = false
[sendemail]
enabled = true
smtpServer = smtp.mxhichina.com
smtpServerPort = 80
smtpUser = XXXXXX@XXXXX.com
smtpPass = XXXXXXXXXXX
smtpEncryption = tls
from = XXXXX@XXXXXXX.com
[container]
user = root
javaHome = /opt/jdk1.8.0_181/jre
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = http://*:8080/
[cache]
directory = cache
[label "Verified"]
defaultValue = 1
replication 插件配置
需要按照要求安装插件,请至少安装如下插件:
- replication
- download-commands
- hooks
root@zabbixserver:~/gerrit/etc# cat replication.config
[remote "gitee.com"]
url = git@gitee.com:arthurlchen/${name}.git
url = git@gitee.com:IntraMirror/${name}.git
push = +refs/heads/*:refs/heads/*
push = +refs/tags/*:refs/tags/*
push = +refs/changes/*:refs/changes/*
timtout = 30
threads = 3
ssh config 配置
root@zabbixserver:~/.ssh# cat config
Host gitee.com
User git
IdentityFile ~/.ssh/id_rsa
StrictHostKeyChecking no
UserKnownHostsFile /dev/null