文档

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

Gerrit管理帐号的更多相关文章

  1. 如何搭建开源code review gerrit服务器

    搭建环境:Ubuntu 14.04 一.环境准备 1.Java环境 gerrit依赖,用于安装gerrit环境. 下载:jdk-7u79-linux-x64.tar.gz http://www.ora ...

  2. 关于Gerrit code review 介绍与安装

    代码审核(Code Review)是软件研发质量保障机制中非常重要的一环,但在实际项目执行过程中,却因为种种原因被Delay甚至是忽略.在实践中,给大家推荐一款免费.开放源代码的代码审查软件Gerri ...

  3. Ubuntu下搭建基于apache2的gerrit+gitweb服务器

    说明:Ubuntu版本12.04 1. 配置gerrit管理帐号 1 sudo adduser gerrit 增加sudo权限: 1 sudo usermod -a -G sudo gerrit 切换 ...

  4. 安装gerrit服务器

    一.环境准备 1.Java环境 gerrit依赖,用于安装gerrit环境. 下载:jdk-7u79-linux-x64.tar.gz http://www.oracle.com/technetwor ...

  5. tomcat linux下的部署安装

    Tomcat在Linux上的安装与配置 转自http://blog.csdn.net/gyming/article/details/36060843     以下使用的Linux版本为: Redhat ...

  6. maven发布项目到私服-snapshot快照库和release发布库的区别和作用及maven常用命令

    maven发布项目到私服-snapshot快照库和release发布库的区别和作用及maven常用命令 在日常的工作中由于各种原因,会出现这样一种情况,某些项目并没有打包至mvnrepository. ...

  7. SQL Server 通过备份文件初始化复制

    一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 搭建过程(Process) 注意事项(Attention) 疑问(Questions) 参考文 ...

  8. SQL Server 复制:事务发布

    一.背景 在复制的运用场景中,事务发布是使用最为广泛的,我遇到这样一个场景:在Task数据库中有Basic与Group两个表,需要提供这两个表的部分字段给其它程序读取放入缓存,程序需要比较及时的获取到 ...

  9. Java类WebServer及中间件拿webshell方法总结

    0.序 原文名称:Tomcat.Weblogic.JBoss.GlassFish.Resin.Websphere弱口令及拿webshell方法总结 原文from:http://www.hack80.c ...

随机推荐

  1. 使用VelocityTracker来完成MotionEvent移动速率计算

    先看效果图 关键代码(此处记录单点): switch (event.getAction()){ case MotionEvent.ACTION_DOWN: if (veloctiy==null) { ...

  2. jeecg安装——mysql数据库创建+手动执行初始化脚本

    国产的开源项目官方文档写得那么详细,已经是很厚道了,可惜俺这种菜鸟还是会碰到各种"小"问题,做个笔记先! 1.新建数据库: CREATE DATABASE jeecg DEFAUL ...

  3. 无法加载父级样式或设置IIS的asp站点启用父路径

    打开IIS 1.单击站点,在"IIS"区域中找到ASP图标,双击. 2.找到"启用父路径"项目,将对应的值设置为"TRUE"即可.   顶

  4. MYSQL之基本操作

    数据库操作 一.查看所有的数据库 show databases; 二.创建数据库 create database userinfo; 说明: 创建了一个名为userinfo的数据库 三.使用数据库 u ...

  5. MySQL基本命令

    1.修改root用户登录密码: [root@17track bin]# /usr/local/mysql/bin/mysqladmin -u root password 'MyPassword' my ...

  6. FMDB 数据库

    iOS中原生的SQLite API在使用上相当不友好,在使用时,非常不便.于是,就出现了一系列将SQLite API进行封装的库,例如FMDB.PlausibleDatabase.sqlitepers ...

  7. SDL鼠标事件

    鼠标事件有这么多种,手柄的可以忽视,Sdl.SDL_KEYDOWN,Sdl.SDL_KEYUP,Sdl.SDL_MOUSEMOTION,Sdl.SDL_MOUSEBUTTONDOWN,Sdl.SDL_ ...

  8. Base64原理

    一.Base64编码由来 为什么会有Base64编码呢?因为有些网络传送渠道并不支持所有的字节,例如传统的邮件只支持可见字符的传送,像ASCII码的控制字符就 不能通过邮件传送.这样用途就受到了很大的 ...

  9. SourceTree推送时,增加额外的远程仓库,不用每次都自定义粘贴复制网络

    一.命令行添加 二.软件界面可以查看到结果 更新,以上是代码添加了远程仓库,最近,找到了不用代码,直接在文件夹里写地址来添加的方式.直接上图了.

  10. html5中新增非主体结构元素

    1.header元素 定义HTML文档的页眉,是一种具有引导和导航作用的结构元素 <header> <h1>header元素</h1> <nav> &l ...