1,下载gerrit软件包(在终端输入如下命令下载);
wget https://gerrit-releases.storage.googleapis.com/gerrit-3.9.0.war
2,新建安装目录
mkdir -p /home/gerrit/gerrit-3.8/gerrit-3.8-install
3,执行命令进行gerrit安装(JDK版本需升级到17.0后才可进行正常安装);
/home/gerrit/jdk-17.0.11/bin/java -jar /home/gerrit/gerrit-3.8.6.war init -d /home/gerrit/gerrit-3.8-install/
根据如下操作进行gerrit相关安装配置:
Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore
[2024-05-28 16:27:43,982] [main] INFO com.google.gerrit.server.config.GerritServerConfigProvider : No /home/gerrit/gerrit-3.8-install/etc/gerrit.config; assuming defaults
*** Gerrit Code Review 3.8.6
***
Create '/home/gerrit/gerrit-3.8-install' [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/?]: LDAP
Git/HTTP authentication [http/?]:
LDAP server [ldap://localhost]: ldap://192.168.1.1 (此IP地址为LDAP地址)
LDAP username : cn=admin,dc=example,dc=com
cn=admin,dc=example,dc=com's password :
confirm password :
Account BaseDN [DC=20,DC=4,DC=27]: ou=admin,dc=example,dc=com
Group BaseDN [ou=physical,dc=example,dc=com]: ou=admin,dc=example,dc=com
Enable signed push support [y/N]? n
Use case insensitive usernames [Y/n]?
*** Review Labels
***
Install Verified label [y/N]?
*** Email Delivery
***
SMTP server hostname [localhost]:
SMTP server port [(default)]:
SMTP encryption [none/?]:
SMTP username :
*** Container Process
***
Run as [root]:
Java runtime [/home/gerrit/jdk-17.0.11]:
Copy gerrit-3.8.6.war to /home/gerrit/gerrit-3.8-install/bin/gerrit.war [Y/n]? y
Copying gerrit-3.8.6.war to /home/gerrit/gerrit-3.8-install/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]?
Use SSL (https://) [y/N]?
Listen on address [*]:
Listen on port [8080]:
Canonical URL [http://localhost:8080/]: http://192.168.1.2:8080/ //此处IP为gerrit服务器实际地址
*** Cache
***
*** Plugins
***
Installing plugins.
Install plugin codemirror-editor version v3.8.6 [y/N]? y
Installed codemirror-editor v3.8.6
Install plugin commit-message-length-validator version v3.8.6 [y/N]? y
Installed commit-message-length-validator v3.8.6
Install plugin delete-project version v3.8.6 [y/N]? y
Installed delete-project v3.8.6
Install plugin download-commands version v3.8.6 [y/N]? y
Installed download-commands v3.8.6
Install plugin gitiles version v3.8.6 [y/N]? y
Installed gitiles v3.8.6
Install plugin hooks version v3.8.6 [y/N]? y
Installed hooks v3.8.6
Install plugin plugin-manager version v3.8.6 [y/N]? y
Installed plugin-manager v3.8.6
Install plugin replication version v3.8.6 [y/N]? y
Installed replication v3.8.6
Install plugin reviewnotes version v3.8.6 [y/N]? y
Installed reviewnotes v3.8.6
Install plugin singleusergroup version v3.8.6 [y/N]? y
Installed singleusergroup v3.8.6
Install plugin webhooks version v3.8.6 [y/N]? y
Installed webhooks v3.8.6
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-3.8-install
Init complete, reindexing accounts,changes,groups,projects with: reindex --site-path /home/gerrit/gerrit-3.8-install --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 (10.0/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.3/s)
Index projects in version 5 is ready
Executing /home/gerrit/gerrit-3.8-install/bin/gerrit.sh start
Starting Gerrit Code Review: OK
Waiting for server on 10.20.4.27:8080 ... OK
Please open the following URL in the browser: http://192.168.1.2:8080/#/admin/projects/[root@localhost gerrit]#
4,在浏览器输入http://IP:8080打开gerrit页面后即可使用LDAP用户访问;