Docker requires a 64-bit OS and version 3.10 or higher of the Linux kernel.
To check your current kernel version, open a terminal and use uname -r to display your kernel version:
12 $ uname -r
3.10.0-229.el7.x86_64
You can install using the yum package manager.
Log into your machine as a user with sudo or root privileges.
Make sure your existing packages are up-to-date.
1 $ sudo yum update
Install JDK or JRE
Download and Install Java. See Java Install Guide for a list of available archives.
1 yum install java-1.8.0-openjdk-devel
Install Latest Git Version
1sudo yum install git
For Git Upgrades, please refer the Git Upgrade for instructions.
Download Gerrit
Download the Gerrit archive. See Gerrit Code Review - Releases for a list of available archives.
12345
cd /opt
sudo yum install wget
wget https://gerrit-releases.storage.googleapis.com/gerrit-2.14.4.war
Install and initialize Gerrit
From the command line, type the following:
1234
# create Gerrit review site with questionaire
java -jar gerrit*.war init -d review_site
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
[root@ip-172-31-29-173 opt]# java -jar gerrit*.war init -d review_site
Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore
[2017-10-01 05:24:19,457] [main] INFO com.google.gerrit.server.config.GerritServerConfigProvider : No /opt/review_site/etc/gerrit.config; assuming defaults
*** Gerrit Code Review 2.14.4
***
Create '/opt/review_site' [Y/n]? Y
Location of Git repositories [git]: git
Database server type [h2]: h2
Type [lucene/?]: lucene
Authentication method [openid/?]: development_become_any_account
Enable signed push support [y/N]? N
Install Verified label [y/N]? N
SMTP server hostname [localhost]: localhost
SMTP server port [(default)]:
SMTP encryption [none/?]:
SMTP username :
Run as [root]:
Java runtime [/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64/jre]:
Copy gerrit-2.14.4.war to review_site/bin/gerrit.war [Y/n]?
Copying gerrit-2.14.4.war to review_site/bin/gerrit.war
Listen on address [*]:
Listen on port [29418]:
Behind reverse proxy [y/N]?
Use SSL (https://) [y/N]?
Listen on address [*]:
Listen on port [8080]:
Canonical URL [http://ip-172-31-29-173.ap-south-1.compute.internal:8080/]: http://13.126.142.202:8080
Installing plugins.
Install plugin commit-message-length-validator version v2.14.4 [y/N]? y
Installed commit-message-length-validator v2.14.4
Install plugin download-commands version v2.14.4 [y/N]? y
Installed download-commands v2.14.4
Install plugin hooks version v2.14.4 [y/N]? y
Installed hooks v2.14.4
Install plugin replication version v2.14.4 [y/N]? y
Installed replication v2.14.4
Install plugin reviewnotes version v2.14.4 [y/N]? y
Installed reviewnotes v2.14.4
Install plugin singleusergroup version v2.14.4 [y/N]? y
Installed singleusergroup v2.14.4
Initializing plugins.
Create administrator user [Y/n]?
username [admin]:
name [Administrator]:
HTTP password [secret]:
public SSH key file []:
email [admin@example.com]:
Initialized /opt/review_site
Executing /opt/review_site/bin/gerrit.sh start
Starting Gerrit Code Review:
OK
1234
# alternatively use the --batch command
java -jar gerrit*.war init -d review_site
The Gerrit instance is installed into the folder specified with the -d parameter, in this example review_site.
If you do not use --batch flag, you can interactively configure the Gerrit instance via a set of questions. A few of these options are discussed in the following table.
Option | Description |
---|---|
Location of Git repositories |
Location of Git repositories, default is the git directory in the installation folder of your Gerrit installation. |
Database server type |
Gerrit supports several databases, by default it uses a preconfigured H2 database. |
Run as user |
Select that Gerrits runs as "root" user. |
Listen on port |
Allows you to configure the port Gerrit is listening to, Gerrit by default listens on port 29418 for SSH access and on port 8080 for web access. This can be changed if the ports are already used. |
Authentication method |
Typical configuring to access the Gerrit server uses LDAP or OpenID Single Sign-on which is the default setting. Use ? to see all available settings for this option. For testing use "development_become_any_account". |
Use development_become_any_account to enable general access to Gerrit. If started with this setting, you have a Become link in the web interface which allows you to login and to create a new account. To enable that authentication method, you can use the following command: git config --file ~/etc/gerrit.config auth.type DEVELOPMENT_BECOME_ANY_ACCOUNT |
1 java -jar gerrit*.war init --batch --dev -d ~/gerrit_testsite
1 java -jar gerrit*.war init -d review_site
The preceding command uses two parameters:
--batch. This parameter assigns default values to a variety of Gerrit configuration options. To learn more about these configuration options, see Configuration.
--dev. This parameter configures the server to use the authentication option, DEVELOPMENT_BECOME_ANY_ACCOUNT. This authentication type makes it easy for you to switch between different users to explore how Gerrit works. To learn more about setting up Gerrit for development, see Developer Setup.
The last message you should see is Starting Gerrit Code Review: OK. This message informs you that the Gerrit service is now running.
Restart the Gerrit service
You must restart the Gerrit service for your authentication type and listen URL changes to take effect.
123456789101112131415
# assumes you installed Gerrit in
# the home directory under gerrit
~/gerrit_testsite/bin/gerrit.sh restart
# assumes you installed Gerrit in
# the home directory under gerrit
# start if not running
~/gerrit/review_site/bin/gerrit.sh start
# stop it again
~/gerrit/review_site/bin/gerrit.sh stop
On Microsoft Windows based systems you need to invoke the daemon directly. From a command shell switch to the folder gerrit_site and run the following command to start the server.
1234
cd gerrit_site
java -jar bin/gerrit.war daemon -d
Viewing Gerrit
At this point, you have a basic installation of Gerrit. You can view this installation by opening a browser and entering the following URL:
1 http://localhost:8080
1234567891011
# mysql -u root -p
CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
SET PASSWORD FOR 'gerrit2'@'localhost' = PASSWORD('XXXXXX'); // your password
CREATE DATABASE reviewdb;
GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
FLUSH PRIVILEGES;
exit
1234
# sudo useradd -m gerrit2
# su - gerrit2