The very first thing you'll want to do is to create a new user on the machine you're intending to run Gerrit on. In our case, we created a user called "gerrit". Then, log into that user.
The next thing you'll have to do is download the official java package.
Download gerrit.war from the Official Gerrit page
Then enter the following command into your command line:
1 | java -jar gerrit.war init -d path/to/site/folder |
This will create the folder you provide in the "-d" argument and start the initialisation dialog. You can run this command again on an already existing Gerrit folder to change its configuration.
Below you can see the configuration dialog from our setup. We went with the default options in most cases (except the http port to listen on, which we set to 8081 because 8080 is already used for Jenkins. Also, we didn't install bouncy castle).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | bash-3.2$ java -jar /Applications/Gerrit/gerrit-2.11.war init -d badgeme Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore *** Gerrit Code Review 2.11 *** Create '/Users/gerrit/Documents/gerrit/badgeme' [Y/n]? *** Git Repositories *** Location of Git repositories [git]: *** SQL Database *** Database server type [h2]: *** Index *** Type [LUCENE/?]: *** User Authentication *** Authentication method [OPENID/?]: *** Review Labels *** Install Verified label [y/N]? *** Email Delivery *** SMTP server hostname [localhost]: SMTP server port [(default)]: SMTP encryption [NONE/?]: SMTP username : *** Container Process *** Run as [gerrit]: Java runtime [/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre]: Copy gerrit-2.11.war to /Users/gerrit/Documents/gerrit/badgeme/bin/gerrit.war [Y/n]? Copying gerrit-2.11.war to /Users/gerrit/Documents/gerrit/badgeme/bin/gerrit.war *** SSH Daemon *** Listen on address [*]: Listen on port [29418]: Gerrit Code Review is not shipped with Bouncy Castle Crypto SSL v151 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]: 8081 Canonical URL [http://mrs.mmlab.mintern.mi.hdm-stuttgart.de:8081/]: *** Plugins *** Installing plugins. Install plugin download-commands version v2.11 [y/N]? Install plugin reviewnotes version v2.11 [y/N]? Install plugin singleusergroup version v2.11 [y/N]? Install plugin replication version v2.11 [y/N]? Install plugin commit-message-length-validator version v2.11 [y/N]? Initializing plugins. No plugins found with init steps. Initialized /Users/gerrit/Documents/gerrit/badgeme Executing /Users/gerrit/Documents/gerrit/badgeme/bin/gerrit.sh start Starting Gerrit Code Review: OK Waiting for server on mrs.mmlab.mintern.mi.hdm-stuttgart.de:8081 ... OK Opening http://mrs.mmlab.mintern.mi.hdm-stuttgart.de:8081/#/admin/projects/ ...OK |
Now the Gerrit server should be live and available both via Server IP + specified port and with the "Canonical URL" that is shown at the end of the setup dialog.
After setting up the server the next thing you'll probably want to do is open the Gerrit page and log in (at least that's the first thing we wanted to do).
If you have access to an LDAP-server, the easiest way for you to log in is probably using that server (you will have to do the configuration again and choose LDAP as authentication method).
In order to create a new project in Gerrit, log in with your previously created account. Then, select the "Projects" tab in the top bar and hit "Create New Project".
Next, enter a name for your project.
After that, choose the rights to inherit from:
If this is the first project you can just inherit from the default "all projects". You can also create a new project just to serve as a parent for other projects which then inherit the settings of the parent project.
From the "Projects" selection in the top bar, you can see a list of all projects by clicking onto "List" below. After clicking on one of them you'll see the options page for this project.
In the project options page you can see (amongst other settings) the URL to use for cloning the Git repository like you would normally do.
As mentioned earlier, deleting projects isn't possible by default (Gerrit prevents you from deleting projects because they have dependencies among themselves. Thus, deleting one project in the chain could have severe ramifications for other projects).
Internally Gerrit sets up a fully functional Git repository which you can clone and push reviews to.
Each project has a unique Git URL you can see in the project options.
Can be set for groups, project owners, admins and registered users in "Projects" > "Access". Permissions include things like: Who is allowed to read, push or submit changes. In addition it can be defined, how much influence certain groups should have over the reviewing process. Permitted users can create projects.
You can see some of the access restrictions that we defined for our project in the screenshot below. Among the important ones are:
At first, install git-review on your mac
1 | brew install git-review |
Rename the remote path of your Gerrit folder to Gerrit:
1 | Git remote rename origin gerrit |
1 | Git review [BRANCH] |
For more information about Git review see:
https://www.mediawiki.org/wiki/Gerrit/git-review
The branch to push to can be specified when submitting reviews.
Branches can be created using the Gerrit UI under Projects > List > PROJECT_NAME > Branches
If you create e.g. a dev branch and want to point it to the current revision of the branch with the name "master" just enter "master" in the revision field.