文档

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. 未封装的js放大镜特效

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>j ...

  2. TWRP基于omnirom 6.0.1编译教程

    1.环境搭配 参照CM13.0编译笔记http://www.cnblogs.com/dinphy/p/5670293.html 参照SM 2.0 编译笔记http://www.cnblogs.com/ ...

  3. Servlet和JSP学习指导与实践(二):Session追踪

    前言: web应用中经常需要对某些有用的信息进行存储或者附加一些信息.本文主要介绍session,即“会话”跟踪的几种不同方式~ ----------------------------4种管理ses ...

  4. c#.NET微信自定义菜单

    private void customMenu() { //获取access_token string access_token = GetAccessToken(); StringBuilder s ...

  5. JQuery 实现标题与内容相呼应样式

    效果图如下:鼠标移到标题上,标题下面显示标题对应的内容.实现的方法如下: 1.引入css和js文件 <link href="public/CSS/StyleSheet.css" ...

  6. Day2-python基础2

    本次学习内容 1.for循环 2.continue and break 3.while循环 4.运算符 5.数据类型 数字 字符串 列表 1.for循环 猜年龄的游戏完善下,只有三次机会 for i ...

  7. js 中关于this用变量存起来的原因

    近来,不忙,总是在网上看大牛的博客,发现关于this指向的情况,有的说是4种,也对,有的就是总结一句话,也对,但是我发现一种特殊情况,例子如下 var show={ btn:$('.div1'), i ...

  8. 写个c++小例子

    class Rational{ public: const Rational operator*( const Rational& rhs); Rational(int num); priva ...

  9. Node.js入门笔记(2):全局对象(1)

    以下将以API文档为基础进行分析学习 global对象 这些对象在所有模块里都可用.有些对象不是在全局作用域而是在模块作用域里,这些情况下面文档都会标注出来. __filename--返回当前模块文件 ...

  10. Shell文件权限和脚本执行

    一.预备知识 1.shell的作用   2.常识 (1)Tab键自动补全   使用Terminal时,输入命令的前几个字母,敲tab会自动补全命令或文件名.目录等. 好处:操作速度更快:不容易出错: ...