Gerrit installation and use instructions

Source: Internet
Author: User
Gerrit installation and use instructions

After several days, I checked a lot of information and finally got rid of it. If something is wrong, let's raise it in time... let's get started.

System

Centos6.5 x64

Memory

2G

Hard Disk

20g

Database

Mysql5.1

Server

Apache2.2

Preparation
#yum update#yum install git#yum install java-1.7.0-openjdk.x86_64#yum install mysql-server#service mysqld start

 

Configure MySQL
#mysql –u root-> CREATE USER ‘gerrit‘@‘localhost‘ IDENTIFIED BY ‘123‘;-> CREATE DATABASE reviewdb;-> ALTER DATABASE reviewdb charset=latin1;-> GRANT ALL ON reviewdb.* TO ‘gerrit‘@‘localhost‘;-> FLUSH PRIVILEGES;

 

Install Gerrit

For the installation file, see [Attachment]

1) always select the default enter (MySQL is selected only when the database is selected, and HTTP is selected when the authentication method is selected)

#java -jar gerrit-full-2.5.war init -d /var/gerrit-site

 

2) The Gerrit configuration file is as follows: (default path:/var/Gerrit-site/etc/Gerrit. conf)

[gerrit]        basePath = git        canonicalWebUrl = http://192.168.1.78:8081/[database]        type = MYSQL        hostname = localhost        database = reviewdb        username = gerrit[auth]        type = HTTP[sendemail]        smtpServer = localhost[container]        user = root        javaHome = /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre[sshd]        listenAddress = *:29418[httpd]        listenUrl = proxy-http://192.168.1.78:8081/[cache]        directory = cache

 

3) Add users. You can add multiple users. This user is used as the login user on the web page.

# touch /var/gerrit-site/passwd# htpasswd /var/gerrit-site/passwd  [new-user-name]

 

4) Start, close, and restart Gerrit

# /var/gerrit-site/bin/gerrit.sh start# /var/gerrit-site/bin/gerrit.sh stop# /var/gerrit-site/bin/gerrit.sh restart

 

Configure Apache

1) Configure reverse proxy

/etc/httpd/conf/httpd.conf…<VirtualHost *:80>  ServerName localhost  ProxyRequests Off  ProxyVia Off  ProxyPreserveHost On  <Proxy *>    Order deny,allow    Allow from all  </Proxy>  <Location /login/>      AuthType Basic      AuthName "Gerrit Code Review"      AuthBasicProvider file      AuthUserFile /var/gerrit-site/password      Require valid-user  </Location>  ProxyPass / http://192.168.1.78:8081/</VirtualHost>

 

2) Disable SELinux and restart it.

# vi /etc/selinux/config…SELINUX=disable…

 

Or, this time is valid

# setenforce 0

 

3) Set permissions

# chown –R apache:apache /var/gerrit-site 

4) disable the firewall to allow LAN users to access

# service iptables stop

 

5) restart the HTTPd service

# service httpd restart

 

Use Gerrit to create a project

Create Branch

 

Configure project Permissions

The code can be submitted to the Branch only after several conditions are met during the project review.

L review> = + 2

L verify> = + 1

Therefore, if you configure a review for each user, you must have at least two persons to complete the review process. Of course, you can also allow a user group to review + 2 at a time.

 

When configuring project permissions, you must configure them as needed. Select the user group with permissions.

 

Obtain Code from the client

Git clone http: // [IP]: [port]/[project-name]. Git

For example, git clone http: // 192.168.1.78/Hello. Git

Add or change files for review

 

Here, the Code submission location is a bit strange: Head: refs/For/master, in fact, it is the method specified by Gerrit, and the final master is the branch name

Code submission shortcut:

[Remote "Review"]

Pushurl = http: // 192.168.1.78/Hello. Git

Push = head: refs/For/Master

In this way, you can directly:

# Git push Review

The user password is "Setting" à "http Password" in the upper-right corner of the webui page"

 

Review page

You can see the "Review" button on the page. Click to review the code.

 

Review or confirmation

At this point, we can see that only one review can be set for the user. This is set in the access of the project. The review result must be greater than or equal to 2. Therefore, the review must be reviewed by two users.

 

Confirm Merging

After Gerrit meets the project requirements (Review> = 2 verify> = 1), the "Submit Patch Set 1" button will appear on the page, and click merge branch to trunk.

 

The user will find that after the submission is complete, the "revert change" button appears, that is, the revert can be submitted just now.

 

Get code again

At this time, you can obtain the branch code of the project from other places and you will see that the code has been updated.

Git pull origin master

Gerrit installation and use instructions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.