Gerrit是一个基于Web的代码评审工具,它基于git版本控制系统。Gerrit旨在提供一个轻量级框架,用于在代码入库之前对每个提交进行审阅,Gerrit会记录每一次提交的代码修改,但只有它们被审阅和接收后才能合入成为项目的一部分。Gerrit部署在中心库位置,Reviewer可以在线对代码检查和评论,只有经过review+2才能合入中心库,增强了中心代码的健壮性。
官方网站:https://www.gerritcodereview.com/
指导文档:https://gerrit-documentation.storage.googleapis.com/Documentation/2.14.6/index.html
我的配置是
Java17 + git 2.33.0 + Apache 2.4.49 + gerrit 3.4.1
Apache:https://httpd.apache.org/
Apache全称为Apache HTTP Server,Apache官方不提供二进制软件,需要用第三方下载如ApacheHaus,需要注意Apache版本和VC Redistributable版本对应
gerrit:https://gerrit-releases.storage.googleapis.com/gerrit-3.4.1.war
1.安装和配置Apahce
#解压压缩包httpd-2.4.49-o111l-x64-vc15.zip
将Apache24文件夹复制到任意目录作为安装位置,该文件夹即可使用
#修改配置Apache/conf/httpd.conf,将SRVROOT值设为Apache具体路径
Define SRVROOT "D:\Users\Apache24"
ServerRoot "${SRVROOT}"
#修改httpd.conf,打开监听端口 默认80
Listen 80
#运行Apache
双击Apache/bin/httpd.exe运行服务,浏览器输入http://localhost/查看是否运行成功,若出现Apache介绍页面即成功
#安装Apache至服务,服务名为Apache24
httpd.exe -k install -n "Apache24"
2.安装和配置Gerrit
#安装gerrit,生成gerrit.config,下载的文件名为gerrit-3.4.1.war
java -jar gerrit-3.4.1.war init -d D:\Users\gerrit
#命令输入后,按提示填写参数
Authentication method [openid/?]: HTTP #认证方法输入HTTP,我们要使用反向代理
#命令结束后生成etc/gerrit.config
#拷贝gerrit.war至bin路径下
copy gerrit-3.4.1.war D:\Users\gerrit\bin\gerrit.war
#启动gerrit
java -jar bin/gerrit.war daemon --console-log
3.创建passwd文件,添加gerrit登录用户
https://httpd.apache.org/docs/2.4/programs/htpasswd.html
#第一次创建用户为管理员,需要 -c 参数,第二次不需要 -c
Apache24/bin/htpasswd.exe -c D:\Users\gerritpsd\.passwd fangjian
#输入密码即可创建完成
4.配置文件修改参考
Apache24/conf/httpd.conf
# 去掉下面几行的注释
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule negotiation_module modules/mod_negotiation.so
#末尾添加以下
<VirtualHost *:80>
ServerName 192.168.41.100
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
<Proxy *:80>
Require all granted
</Proxy>
<Location "/login/">
AuthType Basic
AuthName "Gerrit Code Review"
Require valid-user
AuthBasicProvider file
AuthUserFile D:/Users/gerritpsd/.passwd
</Location>
AllowEncodedSlashes On
ProxyPass / http://192.168.41.100:8080/
</VirtualHost>
#192.168.41.100为本机IP地址,可通过ipconfig命令查看
#AuthBasicProvider
#AuthUserFile为创建的passwd路径
gerrit/etc/gerrit.config
[gerrit]
basePath = git
canonicalWebUrl = http://192.168.41.100:8080/
serverId = 0c464e1a-5da5-4ca5-9664-bceb9533c051
[container]
javaOptions = "-Dflogger.backend_factory=com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance"
javaOptions = "-Dflogger.logging_context=com.google.gerrit.server.logging.LoggingContext#getInstance"
user = fangjian
javaHome = C:\\Program Files\\Java\\jdk-17
[index]
type = lucene
[database]
type = h2
database = db/ReviewDB
[auth]
type = HTTP
[receive]
enableSignedPush = false
[sendemail]
smtpServer = localhost
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = http://*:8080/
[cache]
directory = cache
5.启动Apache+Gerrit
#启动Apache
D:\Users\Apache24\bin\httpd.exe
#启动Gerrit
cd D:\Users\gerrit
java -jar bin\gerrit.war daemon --console-log
6.打开网页Gerrit,输入地址:http://192.168.41.100/
,填写之前注册过的管理员账号和密码即可登录成功
https://www.cnblogs.com/yinzhengjie/p/11007383.html
https://my.oschina.net/superdakevin/blog/617602
nginx:https://juejin.cn/post/6844903559989821453#heading-5
nginx:https://www.cnblogs.com/huxiansheng/p/13397582.html