Gerrit 搭建流程
1 安装java 17
1
| sudo apt install openjdk-17-jdk
|
2 安装git
1
| sudo apt-get install git
|
3 创建目录并下载gerrit 安装包
1
2
3
| mkdir ~/gerrit_site
cd ~/gerrit_site
wget https://gerrit-releases.storage.googleapis.com/gerrit-3.10.1.war
|
4 安装gerrit
1
| java -jar gerrit-3.10.1.war init --batch -d .
|
5 配置插件
1
2
| unzip -oq gerrit-3.10.1.war -d gerrit-3.10.1
cp -r gerrit-3.10.1/WEB-INF/plugins/* plugins/
|
6 配置gerrit
将Auth方式从OPENID改成HTTP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| [gerrit]
basePath = git
canonicalWebUrl = http://jppro2-202311062247356c80ec.debian:8080/
serverId = a77a650a-401d-4168-94c1-5b3c641873b3
[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 = root
javaHome = /usr/lib/jvm/java-17-openjdk-amd64
[index]
type = lucene
[auth]
type = HTTP
[receive]
enableSignedPush = false
[sendemail]
smtpServer = localhost
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = http://*:8080/
[cache]
directory = cache
~
|
7 配置apache2 反向代理
1
2
3
4
| sudo apt-get install apache2
sudo a2enmod proxy
sudo a2enmod proxy_http
vim /etc/apache2/apache2.conf
|
添加如下配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| Listen 8090
<VirtualHost *:8090>
ServerName gerrit
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location /login/>
AuthType Basic
AuthName "Gerrit Code Review"
AuthBasicProvider file
AuthUserFile "/home/username/gerrit_site/etc/passwords" // 修改username为自己用户名
Require valid-user
</Location>
AllowEncodedSlashes On
ProxyPass / http://127.0.0.1:8080/
</VirtualHost>
|
重启服务查看状态
1
2
| sudo /etc/init.d/apache2 restart
sudo systemctl status apache2.service
|
8 创建用户
1
| htpasswd -c ~/gerrit_site/etc/passwords admin
|
9 添加用户
1
| htpasswd -m ~/gerrit_site/etc/passwords person1
|
10 启动gerrit 服务
11 访问服务ip:8090
12 删除创建好的工程
1
| ssh -p 29418 gerrit.example.com delete-project delete --yes-really-delete my-project
|
13 隐藏工程
将继承自All-Project的"refs/heads/*“的Anonymous Users的READ 属性设置成Deny.
遇到的问题:
1
2
| 1. passwords 文件apache2 无法访问,需要给目录和文件都加权限。
调试可以查看/var/log/apache2/error.log
|