文档

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. 腾讯云CentOS Apache开启HTTPS

    1.申请SSL证书 https://console.qcloud.com/ssl?utm_source=yingyongbao&utm_medium=ssl&utm_campaign= ...

  2. XRecyclerView Scrapped or attached views may not be recycled

    将XRecyclerView布局设置为 android:layout_width="match_parent"android:layout_height="match_p ...

  3. 大图居中,以1920px为例

    <div style="overflow: hidden; position: relative;"> <img src="img.jpg" ...

  4. Java的多线程机制系列:(二)缓存一致性和CAS

    一.总线锁定和缓存一致性 这是两个操作系统层面的概念.随着多核时代的到来,并发操作已经成了很正常的现象,操作系统必须要有一些机制和原语,以保证某些基本操作的原子性.首先处理器需要保证读一个字节或写一个 ...

  5. SpringBoot源码分析:spring的基本架构

    在深入了解springboot之前,我们需要了解spring,springboot本身就是基于spring而构建:是微服务架构中一个比较流行的框架:类似spring提供了一套完整的微服务方案如spri ...

  6. 基于 Arduino 的 RFID 识别实验

    http://www.it165.net/embed/html/201512/3287.html 2015年12月04日(周五) 上午  博士的智能卡实验--RFID识别实验,基于51单片机: 我们的 ...

  7. JS自动缩放页面图片

    /** * 缩略图 * * @param bool isScaling 是否缩放 * @param int width 宽度 * @param int height 高度 * @param strin ...

  8. 字符串专题:map POJ 1002

    第一次用到是在‘校内赛总结’扫地那道题里面,大同小异 map<string,int>str 可以专用做做字符串的匹配之类的处理 string donser; str [donser]++ ...

  9. Python自动化之django的ORM

    django ORM操作 1.什么是ORM? ORM,即Object-Relational Mapping(对象关系映射),它的作用是在关系型数据库和业务实体对象之间作一个映射,这样,我们在具体的操作 ...

  10. sqlserver中分区函数 partition by的用法

    partition  by关键字是分析性函数的一部分,它和聚合函数(如group by)不同的地方在于它能返回一个分组中的多条记录,而聚合函数一般只有一条反映统计值的记录, partition  by ...