1.管理员登陆
安装完成第一个登陆的用户会作为管理员
登陆成功
2.基本设置
2.1 Full Name
填入gerrit
点击Save Changes保存
2.2 Add SSH Public Key
生成公钥
[gerrit@localhost ~]$ ssh-keygen -t rsa -C gerrit@test.com
[gerrit@localhost ~]$ cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCydyztelLyfuP1plXLOHvaC8mw2QMa5SJI+LRW+ngczDFTpLCarzS3osDGqsDmYGMKy6D6dR+Y7yXHqnKiBWiMArncGF1AXRw09TKG+A6X2LcfAz532Q6c2oL/y782xU6SmJFZNLzBE3kix+Pe9Lh4HPlfTiCKjZVYBaKXVC9nkZAzrqrWhHfdJ6fPiPUuvJQeUkHKjZfHIEkf7BSeIbmjd3BvUTXBUs451BmT0wvTP/K5W5OlVeUrhYmfo9hhuFt2+sT4M1rG4AfS8v7w/hfqPOWlB284HXrG/bwFjdv1P4VD4Yl5TxK2XboVSPaFEHkpx0a7fCqr+BDXOWm6Qj/1 gerrit@test.com
复制并添加
到此完成了最基本的设置,其他账户也按照此方法设置。
3.添加其他用户完成设置(以highgo为例)
[gerrit@localhost ~]$ htpasswd -m /home/gerrit/gerrit.password highgo
New password:
Re-type new password:
Adding password for user highgo
登陆,完成基本设置
4.操作数据库设置邮箱
由于搭建过程中没有配置邮箱所以不能通过网页注册邮箱,只能由管理员直接操作数据库,添加邮箱信息。
[gerrit@localhost ~]$ ssh -p 29418 -i ~/.ssh/id_rsa 192.168.81.183 -l gerrit
The authenticity of host '[192.168.81.183]:29418 ([192.168.81.183]:29418)' can't be established.
RSA key fingerprint is SHA256:J2gpT+hNoOXQMgWLihVa/sHoYJi9v0rZ6bfG/O6NQ8g.
RSA key fingerprint is MD5:8d:88:d7:23:c9:c0:b1:48:6e:b0:e9:cb:dc:70:12:5b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[192.168.81.183]:29418' (RSA) to the list of known hosts.
**** Welcome to Gerrit Code Review ****
Hi gerrit, you have successfully connected over SSH.
Unfortunately, interactive shells are disabled.
To clone a hosted Git repository, use:
git clone ssh://gerrit@192.168.81.183:29418/REPOSITORY_NAME.git
Connection to 192.168.81.183 closed.
如果出现如下提示,说明没有权限操作
[gerrit@localhost ~]$ ssh -p 29418 -i ~/.ssh/id_rsa 192.168.81.183 -l gerrit gerrit gsql
fatal: gerrit does not have "Access Database" capability.
此时以管理员登陆gerrit
点击Projects => List => All-Projects => Access => Edit
在 Global Capabilities 那部分添加Access Database权限,最后记得点击Save Changes保存
再次连接就有权限了
[gerrit@localhost ~]$ ssh -p 29418 -i ~/.ssh/id_rsa 192.168.81.183 -l gerrit gerrit gsql
Welcome to Gerrit Code Review 2.12.4
(H2 1.3.176 (2014-04-05))
Type '\h' for help. Type '\r' to clear the buffer.
gerrit> select * from ACCOUNT_EXTERNAL_IDS;
ACCOUNT_ID | EMAIL_ADDRESS | PASSWORD | EXTERNAL_ID
-----------+---------------+----------+----------------
1000000 | NULL | NULL | gerrit:gerrit
1000000 | NULL | NULL | username:gerrit
1000001 | NULL | NULL | gerrit:highgo
1000001 | NULL | NULL | username:highgo
(4 rows; 3 ms)
gerrit>
添加邮箱
gerrit> insert into ACCOUNT_EXTERNAL_IDS values('1000000', 'gerrit@test.com', 'NULL', 'mailto:gerrit@test.com');
UPDATE 1; 1 ms
gerrit> insert into ACCOUNT_EXTERNAL_IDS values('1000001', 'highgo@test.com', 'NULL', 'mailto:highgo@test.com');
UPDATE 1; 0 ms
gerrit> select * from ACCOUNT_EXTERNAL_IDS;
ACCOUNT_ID | EMAIL_ADDRESS | PASSWORD | EXTERNAL_ID
-----------+-----------------+----------+-----------------------
1000000 | NULL | NULL | gerrit:gerrit
1000000 | NULL | NULL | username:gerrit
1000001 | NULL | NULL | gerrit:highgo
1000001 | NULL | NULL | username:highgo
1000000 | gerrit@test.com | NULL | mailto:gerrit@test.com
1000001 | highgo@test.com | NULL | mailto:highgo@test.com
(6 rows; 0 ms)
使添加信息生效
[gerrit@localhost ~]$ ssh -p 29418 -i ~/.ssh/id_rsa 192.168.81.183 -l gerrit gerrit flush-caches
然后就可以在网页中设置邮箱了
5. 添加用户组
6.创建Project测试
管理员监听提交
highgo用户clone工程
[highgo@localhost ~]$ git clone ssh://highgo@192.168.81.183:29418/Test.git
添加文件修改
[highgo@localhost ~]$ cd Test/
[highgo@localhost Test]$ touch TestFile.txt
[highgo@localhost Test]$ echo "Test Test Test" >> TestFile.txt
提交
[highgo@localhost Test]$ git add TestFile.txt
[highgo@localhost Test]$ git config user.name highgo
[highgo@localhost Test]$ git config user.email highgo@test.com
[highgo@localhost Test]$ git config remote.origin.push refs/heads/*:refs/for/*
[highgo@localhost Test]$ scp -p -P 29418 highgo@192.168.81.183:hooks/commit-msg .git/hooks/
commit-msg 100% 4662 1.4MB/s 00:00
[highgo@localhost Test]$ git commit -m "add TestFile"
[master 428b57a] add TestFile
1 file changed, 1 insertion(+)
create mode 100644 TestFile.txt
[highgo@localhost Test]$ git push
Counting objects: 4, done.
Writing objects: 100% (3/3), 284 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Processing changes: new: 1, refs: 1, done
remote:
remote: New Changes:
remote: http://192.168.81.183:8081/1 add TestFile
remote:
To ssh://highgo@192.168.81.183:29418/Test.git
* [new branch] master -> refs/for/master
[highgo@localhost Test]$
管理员查看提交
审核并通过
到此完成了基本的简单使用介绍