[Android Software Development] regalstreak:
Gerrit 2.12.2 Setup with Github Sign in​

NOTE: Would be good if you follow the guide in a root environment.

sudo -i

So What is Gerrit?

If you want to know anything else about gerrit then head over to http://gerrit-review.googlesource.com/Documentation/

So lets jump right into setting up gerrit.

1. Getting together everything you need.

2. Getting system ready for installation.

3. Putting together everything and installing gerrit

Section 1: Getting together everything needed

First of you need to make sure have JDK 7 installed on the system.

If you do not have it installed, then:

sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
sudo apt-get update && sudo apt-get install openjdk-7-jre

When you do

java -version

You should see something like OpenJDK 1.7

If not, do this:

sudo update-alternatives --config java

And select 1.7

Next download the Gerrit and Github oauth files

Tip: Use

wget <url>

Gerrit: Latest Releases

Gerrit (What i am using for the tutorial) : 2.12.2

Github oauth library (for 2.12.): github-oauth-2.12-SNAPSHOT.jar

Gerrit Github Plugin: github-plugin-2.12-SNAPSHOT.jar

Note: Visit here for the github plugin and lib if you have a newer gerrit version

Last BUT MOST IMPORTANT

Make sure that you have registered a website domain (like with godaddy.com). Make sure the your dns zone file points your URL to the IP of the machine or server you will be using for gerrit. Or if not, you may use an ip of the vps or something.

Section 2: Getting system ready for installation.

Add Gerrit user and group to the system

sudo useradd gerrit && groupadd gerrit
cd /home
mkdir gerrit
chown -R gerrit:gerrit gerrit

Once you add the user go to the gerrit directory /home/gerrit and create a folder plugins and a folder lib

mkdir lib && mkdir plugins

Setup the database and mysql user

Hope you have mysql server installed and secured. If not, go here:

https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-14-04

mysql -p
CREATE USER 'gerrit'@'localhost' IDENTIFIED BY 'yourpassword';
CREATE DATABASE reviewdb;
GRANT ALL ON reviewdb.* TO 'gerrit'@'localhost';
FLUSH PRIVILEGES;
exit;

Note: Replace yourpassword with a suitable password everywhere in the guide lol

Copying files (downloaded above) to the proper location

cp /root/gerrit-2.12.2.war /home/gerrit
cp /root/github-oauth-2.12-SNAPSHOT.jar /home/gerrit/lib
cp /root/github-plugin-2.12-SNAPSHOT.jar /home/gerrit/plugins

Install to git programs onto the system

sudo apt-get install gitweb
sudo apt-get install git-review

Getting Github ready for gerrit

Setup a new github account for example xosgerrit as a github account

Once you are signed into gerrit under your new Github account go into settings.

If your setting up for team use be sure to add new github account to the team organization!!!!

Next click on the applications...If your doing team click on the organization then on application.

Put in your url to your new gerrit site that you setup in the begining.

If you need visual support for this step [MENTION=5346868]pjgraber03[/MENTION] have a couple pictures

Picture 1

Picuture 2

Section 3: Putting together everything and installing Gerrit

Now you should have everything together that you need to get gerrit up and running.

Initiating Gerrit for this first time

you will need to change into the gerrit directory that you created earlier.

once in the gerrit directory you will need to run the following command

sudo java -jar gerrit*.war init

That will open up into the Gerrit initialisation screen which will look something like this....

The following are just my options....You may wish to change at some point

gerrit@regal-gerrit:~$ sudo java -jar gerrit*.war init
Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore
[2016-05-04 18:38:32,750] [main] INFO com.google.gerrit.server.config.GerritServerConfigProvider : No /home/gerrit/./etc/gerrit.config; assuming defaults

*** Gerrit Code Review 2.12.2
***

*** Git Repositories
***

Location of Git repositories [git]:

*** SQL Database
***

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

*** Index
***

Type [LUCENE/?]:

The index must be rebuilt before starting Gerrit:
java -jar gerrit.war reindex -d site_path

*** User Authentication
***

Authentication method [OPENID/?]: http
Get username from custom HTTP header [y/N]? y
Username HTTP header [SM_USER]: GITHUB_USER
SSO logout URL :
Enable signed push support [y/N]?

*** Review Labels
***

Install Verified label [y/N]?

*** Email Delivery
***

SMTP server hostname [localhost]: smtp.gmail.com
SMTP server port [(default)]: 587
SMTP encryption [NONE/?]: TLS
SMTP username [root]: teamhalogen@gmail.com
teamhalogen@gmail.com's password :
confirm password :

*** Container Process
***

Run as [root]: gerrit
Java runtime [/usr/lib/jvm/java-7-openjdk-amd64/jre]:
Copy gerrit-2.12.2.war to ./bin/gerrit.war [Y/n]?
Copying gerrit-2.12.2.war to ./bin/gerrit.war

*** SSH Daemon
***

Listen on address [*]:
Listen on port [29418]:

Gerrit Code Review is not shipped with Bouncy Castle Crypto SSL v152
If available, Gerrit can take advantage of features
in the library, but will also function without it.
Download and install it now [Y/n]? n
Generating SSH host key ... rsa(simple)... done

*** HTTP Daemon
***

Behind reverse proxy [y/N]?
Use SSL (https://) [y/N]?
Listen on address [*]:
Listen on port [8080]:
Canonical URL [http://regal-gerrit:80/]: http://gerrit.halogenos.org:8080/

*** Plugins
***

Installing plugins.
Install plugin singleusergroup version v2.12.2 [y/N]? y
Install plugin commit-message-length-validator version v2.12.2 [y/N]? y
Install plugin reviewnotes version v2.12.2 [y/N]? y
Install plugin replication version v2.12.2 [y/N]? y
Install plugin download-commands version v2.12.2 [y/N]? y
Initializing plugins.

*** GitHub Integration
***

GitHub URL [https://github.com]:
GitHub API URL [https://api.github.com]:

NOTE: You might need to configure a proxy using http.proxy if you run Gerrit behind a firewall.

*** GitHub OAuth registration and credentials
***

Register Gerrit as GitHub application on:
https://github.com/settings/applications/new

Settings (assumed Gerrit URL: http://gerrit.halogenos.org/)
* Application name: Gerrit Code Review
* Homepage URL: http://gerrit.halogenos.org/
* Authorization callback URL: http://gerrit.halogenos.org/oauth

After registration is complete, enter the generated OAuth credentials:
GitHub Client ID : (ENTER THE APPLICATION CLIENT ID)
GitHub Client Secret : (ENTER THE APPLICATION CLIENT SECRET)
confirm password : (REENTER THE APPLICATION CLIENT SECRET)
Gerrit OAuth implementation [HTTP/?]: http
HTTP Authentication Header [GITHUB_USER]:

Initialized /home/gerrit
gerrit@regal-gerrit:~$

Now, do :

cd /home/gerrit
sudo java -jar gerrit*.war reindex

After that gerrit should only need one last thing

cd in /home and run

sudo chown -R gerrit:gerrit gerrit

this will make all the files in the gerrit folder become owned by the gerrit user/group

Starting gerrit

Once back inside /home/gerrit

run....

sudo bin/gerrit.sh start

That will start gerrit.....

NOTE: STOP apache2 if running on same port: sudo service apache2 stop

To stop gerrit or restart gerrit the commands are...

sudo bin/gerrit.sh stop
or
sudo bin/gerrit.sh restart

All run from /home/gerrit folder

If you run into a FAILED when starting up gerrit you can run

nano logs/error_log

to read the log file and find out what the error is.

One you get a OK when starting gerrit

go ahead and open you browser and type in your URL.

Setting up Gerrit WebUI

First thing is you need to sign in via github to your gerrit using the gerrit github user that you made in the beginning.

once you do that you need to go to your system and go to the /home/gerrit directory and run this

sudo su gerrit
ssh-keygen ( just click enter till its done)
cat .ssh/id_rsa.pub

Some additional links that may provide some help for you

http://gerrit-review.googlesource.com/Documentation/

https://www.packtpub.com/books/conte...-gerrit-github

http://www.vogella.com/tutorials/Gerrit/article.html

https://gerrit.googlecode.com/svn/documentation/2.0/user-upload.html

Huge credits to [MENTION=5346868]pjgraber03[/MENTION] for putting this all up!

Thanks. I just amended stuff for the newest version.