安裝完成第一個登錄的用戶會做爲管理員
登錄成功
git
2.1 Full Name
填入gerrit
點擊Save Changes保存
2.2 Add SSH Public Key
生成公鑰sql
[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
複製並添加
到此完成了最基本的設置,其餘帳戶也按照此方法設置。shell
[gerrit@localhost ~]$ htpasswd -m /home/gerrit/gerrit.password highgo New password: Re-type new password: Adding password for user highgo
登錄,完成基本設置數據庫
因爲搭建過程當中沒有配置郵箱因此不能經過網頁註冊郵箱,只能由管理員直接操做數據庫,添加郵箱信息。ssh
[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保存
code
再次鏈接就有權限了圖片
[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>
添加郵箱ci
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)
使添加信息生效rem
[gerrit@localhost ~]$ ssh -p 29418 -i ~/.ssh/id_rsa 192.168.81.183 -l gerrit gerrit flush-caches
而後就能夠在網頁中設置郵箱了
管理員監聽提交
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]$
管理員查看提交
審覈並經過
到此完成了基本的簡單使用介紹