Gerrit System introduction&Configure&Install // Gerrit 系统初探

in #gerrit10 years ago (edited)

Gerrit introduction // Gerrit 简介

Gerrit is a free, web-based team code collaboration tool. Software developers in a team can review each other's modifications on their source code using a Web browser and approve or reject those changes. It integrates closely with Git, a distributed version control system (from wikipedia)

Gerrit,一种免费、开放源代码的代码审查软件,使用网页界面。利用网页浏览器,同一个团队的软件程序员,可以相互审阅彼此修改后的程序代码,决定是否能够提交,退回或者继续修改。它使用Git作为底层版本控制系统。 (from 百度百科)

Gerrit Configure&Install // Gerrit 审核系统搭建过程

create gerrit2 user // 创建gerrit2用户

$sudo useradd -m -d /home/gerrit2 -s /bin/bash gerrit2

$sudo su gerrit2

Setup mysql&&java environment // 安装mysql以及java环境

apt-get

Configure mysql // 配置mysql

#mysql -u root –p
Mysql>
#CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
#CREATE DATABASE reviewdb;
#ALTER DATABASE reviewdb charset=latin1;
#GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
#FLUSH PRIVILEGES;

Install gerrit and Init // 下载gerrit并进行初始化

$wget http://gerrit-releases.storage.googleapis.com/gerrit-2.7.war
$java -jar gerrit-2.7.war init -d review_site

refer to http://www.infoq.com/cn/articles/Gerrit-jenkins-hudson/
Create '/home/gerrit2/review_site' [Y/n]? Y
Location of Git repositories [git]:
Database server type [h2]: mysql

Gerrit Code Review is not shipped with MySQL Connector/J 5.1.21
** This library is required for your configuration. **
Download and install it now [Y/n]? Y
Downloading http://repo2.maven.org/maven2/mysql/mysql-connector-java/5.1.21/mysql-connector-java-5.1.21.jar
Checksum mysql-connector-java-5.1.21.jar OK
Server hostname [localhost]:
Server port [(mysql default)]:
Database name [reviewdb]:
Database username [gerrit2]:
gerrit2's password : secret
confirm password :
SMTP server hostname [localhost]:
SMTP server port [(default)]:
SMTP encryption [NONE/?]:
SMTP username :

Run Gerrit // 运行gerrit审核系统

$ ./review_site/bin/gerrit.sh start

Login gerrit

default port number:8080

Change gerrit color // 修改gerrit界面颜色

By default the screen color is white which is not what i like. The color configuration change is as bellow:
默认情况下是纯白色的,不美观可以对 review_site/etc/gerrit.config 修改,然后重启服务,下面是一个颜色配置模板:

[theme]

backgroundColor = FCFEEF

textColor = 000000

trimColor = D4E9A9

selectionColor = FFFFCC

topMenuColor = D4E9A9

changeTableOutdatedColor = F08080

[theme "signed-in"]

backgroundColor = FCFEEF

textColor = 000000

trimColor = D4E9A9

selectionColor = FFFFCC

topMenuColor = D4E9A9

changeTableOutdatedColor = F08080

More info refer to https://gerrit-review.googlesource.com/Documentation/config-gerrit.html#_a_id_theme_a_section_theme

Gerrit test // Gerrit 系统正常测试

ssh -p 29418 username@webhost to test whether gerrit is running well,based on http://www.infoq.com/cn/articles/Gerrit-jenkins-hudson/, we can do some ssh configuration,It would show these following info after success:

**** Welcome to Gerrit Code Review ****

Hi demo, you have successfully connected over SSH.

Unfortunately, interactive shells are disabled.
To clone a hosted Git repository, use:

git clone ssh://demo@localhost:29418/REPOSITORY_NAME.git

Connection to localhost closed.

Create the first project // Gerrit创建第一个项目

ssh -p 29418 admin@localhost gerrit create-project --name example.git

Github+gerrit+Jenkins(hudson) +redmine

Responsibility // 职责:

GitHub is a resource for managing Git code repositories and interacting with other developers. Jenkins is used to continuously test all of the components of OpenStack to ensure functionality and to verify that each change to the code base works as intended. Gerrit is a code review system originally developed for use by the Android Open Source Project and allows us to build a workflow where every change is peer-reviewed and tested by Jenkins before being merged into the main repository.

Workflow // 工作流:

developer checks out source from github.
developer makes changes.
developer pushes to gerrit.
gerrit sends change notice to jenkins for integration test.
jenkins pulls changes directly from gerrit git server.
on pass, jenkins adds +1 to gerrit review, passes review to other developers.
on failure, jenkins adds -1 to gerrit review
pass/fail status pushed to redmine
other developers review change, approve (+2)
gerrit commits changes to github repository.
github hook notifies redmine of updates.
redmine pulls changes from github, parses commit messages for ticket information.
developer fetchs changes from github ... back to 2. [EDIT]: we switched to pulling directly from gerrit. Github remains as a mirror for pulling production sources.
Run Jenkins

Based on https://wiki.jenkins-ci.org/display/JENKINS/Gerrit+Trigger, we can configure jenkins and Gerrit

jenkins + github http://blog.csdn.net/john_cdy/article/details/7738393

java -jar jenkins.war --httpPort=$PORT --httpListenAddress=$HTTP_HOST

how to use jenkins: https://wiki.jenkins-ci.org/display/JENKINS/Use+Jenkins

http://fourkitchens.com/blog/2011/09/20/trigger-jenkins-builds-pushing-github

Available Links:

Jenkins 学习:http://www.cnblogs.com/itech/archive/2011/11/23/2260009.html

Gerrit 学习:http://ci.openstack.org/gerrit.html (介绍了OpenStack源代码开发维护更新流程!)

Gerrit introduction: http://gerrit-documentation.googlecode.com/svn/Documentation/2.6/intro-quick.html

Gerrit installation: http://gerrit.googlecode.com/svn/documentation/2.1.6/install.html

Git、Gerrit与Jenkins/Hudson CI服务器:

http://www.infoq.com/cn/articles/Gerrit-jenkins-hudson/

GerritJenkinsGithub: https://wiki.openstack.org/wiki/GerritJenkinsGithub

Ideas and Actions: https://groups.google.com/forum/#!msg/repo-discuss/rersrCtdEiY/usAodLofFo8J

Gerrit 工作流: https://wiki.openstack.org/wiki/GerritWorkflow

git diff 的用法: http://blog.sina.com.cn/s/blog_40e9d4dd0100xi8p.html

git rebase用法: http://www.cnblogs.com/kym/archive/2010/08/12/1797937.html

Gerrit 安装:http://ci.openstack.org/gerrit.html

图解GIT: http://nettedfish.sinaapp.com/blog/2013/08/05/deep-into-git-with-diagrams/

Sort:  

Nice @linvictor88
Shot you an Upvote :)

该文是我原创,原文链接在http://www.cnblogs.com/lin-victor/p/3437418.html. 证明的方法是: 1. 两个作者名字很像,因为seemit不允许下划线所以省略掉下划线 2. 已经将原文标头修改提示转移到该链接中 3. cnblog 保证自己的文章是原创,如果不是原创,已经被删掉了

那边的排版好像比这里好。

对的,我不会用markdown,只是简单的设置了下heading,有时间学学markdown,这个是seemit需要改善的地方,cnblog提供富文本编辑功能,所以很容易通过类似word的方式排版

Congratulations @linvictor88! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 3 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Keep up the great work @linvictor88
Upvoted

Coin Marketplace

STEEM 0.04
TRX 0.33
JST 0.083
BTC 62069.28
ETH 1614.34
USDT 1.00
SBD 0.45