前提
- 當前登錄用戶爲 z
- 新用戶對應的郵箱爲 [email protected],並已經創建。如果當前系統 z 已經存在SSH祕鑰,則用祕鑰中包含的郵箱。
系統上生成生成SSH祕鑰
如果已經存在就用原來的祕鑰和郵箱,如果不存在就重新創建
$ cat ~/.ssh/id_rsa.pub
$ ssh-keygen -C z@vzjc.com
$ cat ~/.ssh/id_rsa.pub
Gitlab系統上註冊賬戶
賬戶名爲 ‘z’, 郵箱爲 [email protected], 對應的SSH祕鑰位於Mac用戶 z 上
如果用的是Mac用戶 z 的已經存在的SSH祕鑰,則郵箱可能不同
Gitlab系統註冊頁面
郵箱驗證,註冊成功
Gitlab系統賬戶 z 的配置
- 用 root 登錄Gitlab系統 http://gitlab.zjc.com
- 將用戶 z 以 Reporter 身份添加到組 dev-group 中
- 以 z 登錄Gitlab系統,更新SSH公鑰
Gerrit系統註冊賬戶
需要登錄服務器所在的Ubuntu系統,運行命令
$ sudo -u gerrit -H htpasswd /home/gerrit/gerrit/etc/htpasswd.conf z
Gerrit系統賬戶 z 的配置
- 用賬戶 z 登錄 Gerrit系統 http://review.zjc.com
- 更新郵箱爲 [email protected] 根據具體情況配置
- 添加前面得到的SSH公鑰
Mac上代碼
Mac上用 z 賬戶登錄
$ git clone [email protected]:dev-group/test-project1.git
$ cd test-project1/
$ touch test3
$ git add .
$ git commit -m 'add test3' -s
$ git config user.name 'z'
$ git config user.email '[email protected]'
$ git review
$ git commit --amen
$ git review
餘下的操作
- 管理員賬號登陸Gerrit,可以看到Jenkins已經 Verifed + 1 了,管理員操作 Code Reviewed + 2, 然後點擊 Submit 按鈕
- 登錄Gitlab,可以看到剛纔提交的修改已經Merge了
可能出現的問題
不能識別命令 git review
解決方案:
安裝 git review 參照教程
無法連接 gerrit
現象:
調用 git review後,出現錯誤提示
Could not connect to gerrit.
Enter your gerrit username:
解決方案:
刪除 ~/.ssh/known_hosts 文件