gerrit 环境搭建
R1 - Gerrit 环境搭建
环境说明
- ubuntu 20.04
- Gerrit 3.8.0
- openjdk version “11.0.19” 2023-04-18
安装依赖软件包
sudo apt install openjdk-11-jdk openjdk-11-jdk-headless openjdk-11-jre openjdk-11-jre-headless
创建 Gerrit 用户
sudo adduser gerrit
sudo usermod -a -G sudo gerrit
sudo su gerrit
mkdir ~/gerrit
java -jar gerrit-3.8.0.war init -d ~/gerrit
安装 Gerrit
$ java -jar gerrit-3.8.0.war init -d ~/gerrit
Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore
[2023-06-03 12:19:03,027] [main] INFO com.google.gerrit.server.config.GerritServerConfigProvider : No /home/gerrit/gerrit/etc/gerrit.config; assuming defaults
*** Gerrit Code Review 3.8.0
***
Create '/home/gerrit/gerrit' [Y/n]? Y
*** Git Repositories
***
Location of Git repositories [git]:
*** JGit Configuration
***
Auto-configured "receive.autogc = false" to disable auto-gc after git-receive-pack.
*** Index
***
Type [lucene]:
*** User Authentication
***
Authentication method [openid/?]: ?
Supported options are:
openid
openid_sso
http
http_ldap
client_ssl_cert_ldap
ldap
ldap_bind
custom_extension
development_become_any_account
oauth
Authentication method [openid/?]: http
Get username from custom HTTP header [y/N]? y
Username HTTP header [SM_USER]:
SSO logout URL :
Enable signed push support [y/N]? y
Use case insensitive usernames [Y/n]? Y
*** Review Labels
***
Install Verified label [y/N]? N
*** Email Delivery
***
SMTP server hostname [localhost]:
SMTP server port [(default)]:
SMTP encryption [none/?]:
SMTP username :
*** Container Process
***
Run as [gerrit]:
Java runtime [/usr/lib/jvm/java-11-openjdk-amd64]:
Copy gerrit-3.8.0.war to /home/gerrit/gerrit/bin/gerrit.war [Y/n]? Y
Copying gerrit-3.8.0.war to /home/gerrit/gerrit/bin/gerrit.war
*** SSH Daemon
***
Listen on address [*]:
Listen on port [29418]:
Generating SSH host key ... rsa... ed25519... ecdsa 256... ecdsa 384... ecdsa 521... done
*** HTTP Daemon
***
Behind reverse proxy [y/N]? y
Proxy uses SSL (https://) [y/N]? N
Subdirectory on proxy server [/]:
Listen on address [*]:
Listen on port [8081]:
Canonical URL [http://luyang-VirtualBox/]:
*** Cache
***
*** Plugins
***
Installing plugins.
Install plugin codemirror-editor version v3.8.0 [y/N]? y
Installed codemirror-editor v3.8.0
Install plugin commit-message-length-validator version v3.8.0 [y/N]? y
Installed commit-message-length-validator v3.8.0
Install plugin delete-project version v3.8.0 [y/N]? y
Installed delete-project v3.8.0
Install plugin download-commands version v3.8.0 [y/N]? y
Installed download-commands v3.8.0
Install plugin gitiles version v3.8.0 [y/N]? y
Installed gitiles v3.8.0
Install plugin hooks version v3.8.0 [y/N]? y
Installed hooks v3.8.0
Install plugin plugin-manager version v3.8.0 [y/N]? y
Installed plugin-manager v3.8.0
Install plugin replication version v3.8.0 [y/N]? y
Installed replication v3.8.0
Install plugin reviewnotes version v3.8.0 [y/N]? y
Installed reviewnotes v3.8.0
Install plugin singleusergroup version v3.8.0 [y/N]? y
Installed singleusergroup v3.8.0
Install plugin webhooks version v3.8.0 [y/N]? y
Installed webhooks v3.8.0
Initializing plugins.
============================================================================
Welcome to the Gerrit community
Find more information on the homepage: https://www.gerritcodereview.com
Discuss Gerrit on the mailing list: https://groups.google.com/g/repo-discuss
============================================================================
Initialized /home/gerrit/gerrit
Init complete, reindexing accounts,changes,groups,projects with: reindex --site-path /home/gerrit/gerrit --threads 1 --index accounts --index changes --index groups --index projectsReindexed 0 documents in accounts index in 0.0s (0.0/s)
Index accounts in version 12 is ready
Reindexing groups: 100% (2/2)
Reindexed 2 documents in groups index in 0.2s (9.9/s)
Index groups in version 9 is ready
Reindexing changes: Slicing projects: 100% (2/2), done
Reindexed 0 documents in changes index in 0.0s (0.0/s)
Index changes in version 82 is ready
Reindexing projects: 100% (2/2)
Reindexed 2 documents in projects index in 0.1s (25.0/s)
Index projects in version 5 is ready
Executing /home/gerrit/gerrit/bin/gerrit.sh start
Starting Gerrit Code Review: WARNING: Could not adjust Gerrit's process for the kernel's out-of-memory killer.
This may be caused by /home/gerrit/gerrit/bin/gerrit.sh not being run as root.
Consider changing the OOM score adjustment manually for Gerrit's PID=4510 with e.g.:
echo '-1000' | sudo tee /proc/4510/oom_score_adj
OK
Waiting for server on luyang-VirtualBox:80 ... OK
Please open the following URL in the browser: http://luyang-VirtualBox/#/admin/projects/
配置 Gerrit
etc/gerrit.config
[gerrit]
basePath = git
canonicalWebUrl = http://192.168.56.104:8080
serverId = d00cca90-af13-4298-9273-72d50cce94ce
[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 = gerrit
javaHome = /usr/lib/jvm/java-11-openjdk-amd64
[index]
type = lucene
[auth]
type = HTTP
httpHeader = SM_USER
userNameCaseInsensitive = true
[receive]
enableSignedPush = true
[sendemail]
enable = true
smtpServer = smtp.qq.com
smtpServerPort = 465
smtpEncryption = SSL
sslVerify = true
smtpUser = 193944320@qq.com
smtpPass = fjas;jfa;sdjfalk
from = [SCM]<193944320@qq.com>
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = proxy-http://*:8081/
[cache]
directory = cache
安装配置 Nginx
sudo apt install nginx
/etc/nginx/conf.d/gerrit.conf
server {
listen *:8080;
server_name 192.168.56.104;
allow all;
deny all;
auth_basic "Welcomme to Gerrit Code Review Site!";
auth_basic_user_file /home/gerrit/gerrit/etc/gerrit.password;
location / {
proxy_redirect off;
proxy_pass http://192.168.56.104:8081;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}