Before git add-->git commit-->git push
the orange line in the figure
Gerrit is the bird in the picture above. The code of ordinary members is first pushed to the gerrit server, and then the code reviewer, the integrator in the upper left corner, performs the code review (review
) on the web page. After passing (approve
), this time the code will be submitted (submit
) to the code repository (repo
).
Code review passed or rejected, the code submitter (Contributor
) and all related code reviewers (Integrator
) will receive email reminders
Gerrit also has an automatic test function. Code that conflicts with the main line or fails the test will be directly rejected. This function seems to be the task of the old man (Jenkins
) in the lower right corner.
When doing commit
, a Change-Id
must be generated, otherwise, when pushing to the gerrit server, you will receive an error reminder
The committer cannot directly push the code to the remote master
mainline (or other remote branches). This is equivalent to crossing gerrit. Gerrit must depend on a branch of refs/for/*
.
If we have only one master mainline remotely, then only when your code is submitted to the refs/for/master
branch, gerrit will know that I have received a code push that needs to be reviewed, and I need to notify the reviewer to review the code .
After the review is passed, gerrit will automatically merge this branch into the master main line, and then notify the relevant members by email that there is an update to the master branch, and the members that need it will be pulled. And this branch of refs/for/master
is transparent, which means that ordinary members do not need to know this line. If you configure sourceTree
correctly, you should not see this line. of
For convenience, I use the installation on the VMware Workstation Pro virtual machine, and ubuntu can go directly to the official website to download. The installation steps are straightforward. After installation, change the language to Chinese. The Ubuntu terminal supports Chinese display and switch input methods. ;
When the system is ready, you must first root
to install subsequent support packages/programs/create users, etc.
sudo passwd
# [ sudo]Tw password: sudo is actually a root command of Ubuntu, just enter your password and press Enter
# After creating
su - #Switch to root user
# root@ubuntu:~#Is the successful switching
Let me post the instructions that I will use frequently in the follow-up
sudo apt-get update update source
sudo apt-get install package install package
sudo apt-get remove package delete package
sudo apt-get upgrade Update installed packages
mkdir -p code/string #Create a new string folder plus-p means that you can praise the directory operation or add it to the current directory
touch code/string/lesson.js #New lesson.js file
sudo rm -rf +Files to be deleted
vim editing commands, used when you need to edit a text
i + Esc +Shift ZZ save edit
i + Esc + :+! Do not save edits
cat view
whereis +File name to be queried#search for
# Important, need to start every time#
/home/gerrit/gerrit_site/bin/gerrit.sh restart restart gerrit
service nginx restart restart nginx
# important#
sudo apt-get update
sudo apt-get install git
sudo apt install vim
apt-cache search openjdk
sudo apt-get install openjdk-8-jdk
vim ~/.bashrc
java -versionjava
sudo apt install nginx
sudo systemctl status nginx
service nginx restart
nginx needs to create a new configuration file /etc/nginx/conf.d/gerrit.conf
server {
listen *:81;
server_name gerrit.microwu.com;
allow all;
deny all;
auth_basic "Welcomme to Gerrit Code Review Site!";
auth_basic_user_file /home/gerrit/gerrit.password;
location /{
proxy_pass http://127.0.0.1:8080;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;}}
sudo apt-get install gcc-5
sudo apt-get install g++-5
sudo apt-get install build-essential
sudo apt-get install ubuntu-make
sudo apt-get install net-tools
sudo apt install apache2
sudo apt install apache2-utils
sudo apt-get install libxml2-dev
sudo apt-get install libbz2-dev
Download the self-built catalog
cd php-5.5.13./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-inline-optimization
- - disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm
- - with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd
- - with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring
- - with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap
- - with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem
- - enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2
- - with-readline --without-sqlite3 --without-pdo-sqlite --with-pear
adduser gerrit
su gerrit
Download the installation package and copy it to /home/gerrit/
java -jar gerrit-2.13.4.war init -d ~/gerrit_site #Unzip and install
The installation process only needs to see the input of http
when configuring the Authenticationmethod
and press Enter for all others; create a new user in the directory /home/gerrit/
$ htpasswd -c /home/gerrit/gerrit.password admin
$ htpasswd -m /home/gerrit/gerrit.password master
Modify the gerrit configuration file /home/gerrit/gerrit_site/etc/gerrit.config, my configuration file for reference and comparison
[ gerrit]
basePath = git
serverId = bd3a7d07-58c8-42ac-8a0d-5d8d205ed3fb
canonicalWebUrl = http://http://192.168.96.130:8080/[database]
type = h2
database =/home/gerrit/gerrit_site/db/ReviewDB
[ noteDb "changes"]
disableReviewDb =true
primaryStorage = note db
read =true
sequence =true
write =true[container]
javaOptions ="-Dflogger.backend_factory=com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance"
javaOptions ="-Dflogger.logging_context=com.google.gerrit.server.logging.LoggingContext#getInstance"
user = root
javaHome =/usr/lib/jvm/java-8-openjdk-amd64/jre
[ index]
type = LUCENE
[ auth]
type = HTTP
[ receive]
enableSignedPush =false[sendemail]
smtpServer = smtp.ym.163.com
smtpServerPort =25
smtpEncryption = SSL
smtpUser = [email protected]
smtpPass = xiangy1234
from= [email protected]
[ sshd]
listenAddress =*:29418[httpd]
listenUrl = http://*:8080/
[ cache]
directory = cache
If it is installed step by step, I only need to modify the sendemail content, here is the content of the configuration mailbox, because the 163 mailbox used by our department is configured according to the 163 stmp content; after configuration, restart gerrit and nginx ;
/home/gerrit/gerrit_site/bin/gerrit.sh restart restart gerrit
service nginx restart restart nginx
Check the port information after restarting for reference
netstat -ltpn
PID/Program name
tcp 000.0.0.0:800.0.0.0:* LISTEN 26246/nginx: master
tcp 000.0.0.0:810.0.0.0:* LISTEN 26246/nginx: master
tcp 00127.0.0.53:530.0.0.0:* LISTEN 107306/systemd-reso
tcp 00127.0.0.1:6310.0.0.0:* LISTEN 25265/cupsd
tcp6 00:::29418:::* LISTEN 26454/GerritCodeRev
tcp6 00:::8080:::* LISTEN 26454/GerritCodeRev
tcp6 00:::80:::* LISTEN 26246/nginx: master
tcp6 00::1:631:::* LISTEN 25265/cupsd
After confirming that gerrit and nginx have port information, open the browser and enter your ip:81
, a login window will be displayed first
Enter the admin account and password
Displaying this interface indicates that the deployment of the gerrit environment is complete!
# Attached delete method#
/home/gerrit/gerrit_site/bin/gerrit.sh stop
Then delete it directly/home/gerrit/gerrit_site/Entire folder
$ ps -ef | grep gerrit
Recommended Posts