文檔
Gerrit服務器啟動后,網站上有一個Documentation鏈接。點擊后會看到四個選項:
index,searching,uploading和access control
文檔內容很多,不必專門去Gerrit官方查找。
創建CI服務器使用的帳號
CI服務器比如Jenkins肯定需要訪問Gerrit來獲取最新的源代碼進行編譯。
1.你必須在管理員所在的客戶端執行命令。也就是說,你執行命令的本地機器已經作為管理員加入到Gerrit系統中。
2.將CI服務器上的公鑰文件拷貝到本地機器上,假定放在了~/目錄下
3.執行命令,創建帳號
1
|
cat
~
/id_rsa
.pub |
ssh
-p 29418 your_server gerrit create-account --group your_group --full-name usa1 --email your_email --
ssh
-key - usa1
|
提示:
gourp name如果包含空格,應該用引號包起來,並且用\引導。比如:
1
|
create-account --group
'Build\ Users'
|
- -ssh-key 參數后用 - 表示從標准輸入獲取公鑰內容,這里最開頭用了cat ~/id_rsa.pub | 方式剛好提供了所需。
email和用戶名不允許和已有用戶重復,但是公鑰允許重復。
4.到CI所在服務器上,用命令clone項目。
1
|
git clone
ssh
:
//usa1
@your_server:29418
/your_project
.git
|
查詢和刪除帳號
需要到數據庫中查找和刪除。沒有其他途徑。
如果使用的是H2數據庫,確保Gerrit服務啟動的情況下,使用下面的命令就可以登錄遠程數據庫。(之前我弄錯了端口號,其實真的很簡單)
1
|
ssh
-p 29418 user@my_server gerrit gsql
|
如果當前登錄的Linux用戶名和Gerrit上注冊的用戶名不一樣,需要在參數中指明正確用戶名。比如:
1
|
ssh
-p 29418 shuchen@my_server gerrit gsql
|
或者直接登錄gerrit服務器,關閉gerrit服務后,用下面的命令啟動:
1
|
java -jar gerrit-2.3.war gsql -d .
/review_site/
|
修改用戶名
1
|
update ACCOUNT_EXTERNAL_IDS
set
external_id=
'username:chenshu'
where external_id=
'username:shuchen'
;
|
上面的sql語句將用戶名從shuchen換成了chenshu
數據庫操作問題1:
最近發現增刪賬號等數據庫操作的要求越來越頻繁,而通過ssh gerrit gsql進入數據庫操作還是比較繁瑣的。
查找Gerrit Document會發現有如下用法:
ssh -p <port> <host> gerrit gsql [--format {PRETTY | JSON}] [-c QUERY]
嘗試一條簡單的命令ssh -p 29418 server gerrit gsql -c "select * from accounts"
報錯: fatal: No argument is allowed: *
嘗試一條簡單的命令ssh -p 29418 server gerrit gsql -c "select ALL from accounts"
報錯: fatal: No argument is allowed: ALL
知識有限,暫時沒轍了。果斷掛代理上google,得到如下結果:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
On Wed, Aug 10, 2011 at 4:43 PM, bruce zu <
zu.bruc...
@gmail.com> wrote:
Hi , Dear All
my colleague find gerrit sshd function about gsql not good
enough , I check it and find
It is not about gsql function but about quoting the command properly in your shell which can be tricky.
ssh <
name
>@<
host
> -p 29419 gerrit gsql -c "select * from
accounts"
have you tried:
ssh <
name
>@<
host
> -p 29419 gerrit gsql -c \"select \* from accounts\"
You need to backslash the *, otherwise the shell will glob it and replace with all files in the current folder.
can not work , gerrit will say it will not support '*'.
ssh <
name
>@<
host
> -p 29419 gerrit gsql -c "select full_name
from accounts"
ssh <
name
>@<
host
> -p 29419 gerrit gsql -c \"select full_name from accounts\"
can not work , gerrit will say full_name is not a column name.
ssh <
name
>@<
host
> -p 29419 gerrit gsql -c "SELECT FULL_NAME FROM
ACCOUNTS"
can not work , gerrit will pending there and without giving any
error or other information after I waiting it for more than half an
hour.
I don't understand how is this different than the previous example with lowercase SQL string.
Anyway, if it hangs then create a thread dump of the Gerrit process and see if there are any threads
waiting in a JDBC driver call. If yes, then your database is not responding... or not responding quick enough.
Sasa Zivkov
|
結果很明了,要用ssh Server gerrit gsql -c \"select \* from accounts\"
一般情況下刪除一個賬號需要用到如下command:
ssh 3188 gerrit gsql -c \"select \* from accounts where preferred_email=\'James_Bond@xxx.com\'\"
1000274 1000766
ssh 3188 gerrit gsql -c \"delete from ACCOUNTS where account_id=1000766\"
ssh 3188 gerrit gsql -c \"delete from ACCOUNT_EXTERNAL_IDS where account_id=1000766\"
ssh 3188 gerrit gsql -c \"delete from ACCOUNT_GROUP_MEMBERS where account_id=1000766\"
ssh 3188 gerrit gsql -c \"delete from ACCOUNT_GROUP_MEMBERS_AUDIT where account_id=1000766\"
ssh 3188 gerrit gsql -c \"delete from ACCOUNT_GROUP_NAMES where account_id=1000766\"
ssh 3188 gerrit gsql -c \"delete from ACCOUNT_SSH_KEYS where account_id=1000766\"
百度空間太坑爹了,自今天其全面轉移到博客園。。。
附原鏈接http://hi.baidu.com/hengbo0926/item/d65b33c23d07f22ea0b50ac0