blob: d665226798653a63022cfc8e3e32c11d99ad49c2 [file] [log] [blame]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08001= Gerrit Code Review - Quick get started guide
Fredrik Luthandera75dadc2011-10-28 06:58:18 +02002
3****
4This guide was made with the impatient in mind, ready to try out Gerrit on their
5own server but not prepared to make the full installation procedure yet.
6
7Explanation is sparse and you should not use a server installed this way in a
8live setup, this is made with proof of concept activities in mind.
9
10It is presumed you install it on a Unix based server such as any of the Linux
11flavors or BSD.
12
13It's also presumed that you have access to an OpenID enabled email address.
David Pursehouse221d4f62012-06-08 17:38:08 +090014Examples of OpenID enable email providers are Gmail, Yahoo! Mail and Hotmail.
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020015It's also possible to register a custom email address with OpenID, but that is
16outside the scope of this quick installation guide. For testing purposes one of
17the above providers should be fine. Please note that network access to the
18OpenID provider you choose is necessary for both you and your Gerrit instance.
19****
20
21
22[[requirements]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080023== Requirements
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020024
25Most distributions come with Java today. Do you already have Java installed?
26
27----
28 $ java -version
David Ostrovsky3931c162014-06-15 00:33:40 +020029 openjdk version "1.8.0_72"
30 OpenJDK Runtime Environment (build 1.8.0_72-b15)
31 OpenJDK 64-Bit Server VM (build 25.72-b15, mixed mode)
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020032----
33
34If Java isn't installed, get it:
35
David Pursehouse7b409442016-11-15 12:11:21 -080036* JRE, minimum version 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html[Download]
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020037
38
39[[user]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080040== Create a user to host the Gerrit service
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020041
David Pursehouse221d4f62012-06-08 17:38:08 +090042We will run the service as a non-privileged user on your system.
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020043First create the user and then become the user:
44
45----
Carlo Marcelo Arenas Belon78df6192012-01-31 02:58:41 -080046 $ sudo adduser gerrit2
47 $ sudo su gerrit2
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020048----
49
David Pursehouse221d4f62012-06-08 17:38:08 +090050If you don't have root privileges you could skip this step and run Gerrit
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020051as your own user as well.
52
53
54[[download]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080055== Download Gerrit
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020056
David Pursehouse221d4f62012-06-08 17:38:08 +090057It's time to download the archive that contains the Gerrit web and ssh service.
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020058
59You can choose from different versions to download from here:
60
Shawn Pearce6d7ebc62015-06-12 16:34:42 -070061* https://www.gerritcodereview.com/download/index.html[A list of releases available]
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020062
Carlo Marcelo Arenas Belon78df6192012-01-31 02:58:41 -080063This tutorial is based on version 2.2.2, and you can download that from this link
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020064
Shawn Pearce6d7ebc62015-06-12 16:34:42 -070065* https://www.gerritcodereview.com/download/gerrit-2.2.2.war[Link to the 2.2.2 war archive]
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020066
67
68[[initialization]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080069== Initialize the Site
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020070
71It's time to run the initialization, and with the batch switch enabled, we don't have to answer any questions at all:
72
73----
Carlo Marcelo Arenas Belon78df6192012-01-31 02:58:41 -080074 gerrit2@host:~$ java -jar gerrit.war init --batch -d ~/gerrit_testsite
75 Generating SSH host key ... rsa(simple)... done
76 Initialized /home/gerrit2/gerrit_testsite
77 Executing /home/gerrit2/gerrit_testsite/bin/gerrit.sh start
78 Starting Gerrit Code Review: OK
79 gerrit2@host:~$
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020080----
81
82When the init is complete, you can review your settings in the
83file `'$site_path/etc/gerrit.config'`.
84
David Pursehouse19f067e2012-06-14 13:40:09 +090085Note that initialization also starts the server. If any settings changes are
86made, the server must be restarted before they will take effect.
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020087
88----
David Pursehouse19f067e2012-06-14 13:40:09 +090089 gerrit2@host:~$ ~/gerrit_testsite/bin/gerrit.sh restart
90 Stopping Gerrit Code Review: OK
91 Starting Gerrit Code Review: OK
Carlo Marcelo Arenas Belon78df6192012-01-31 02:58:41 -080092 gerrit2@host:~$
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020093----
David Pursehouse19f067e2012-06-14 13:40:09 +090094
95The server can be also stopped and started by passing the `stop` and `start`
96commands to gerrit.sh.
97
98----
99 gerrit2@host:~$ ~/gerrit_testsite/bin/gerrit.sh stop
100 Stopping Gerrit Code Review: OK
101 gerrit2@host:~$
102 gerrit2@host:~$ ~/gerrit_testsite/bin/gerrit.sh start
103 Starting Gerrit Code Review: OK
104 gerrit2@host:~$
105----
106
Jason Huntleydd210012012-07-30 13:53:45 -0400107include::config-login-register.txt[]
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200108
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800109== Project creation
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200110
111Your base Gerrit server is now running and you have a user that's ready
112to interact with it. You now have two options, either you create a new
113test project to work with or you already have a git with history that
David Pursehouse221d4f62012-06-08 17:38:08 +0900114you would like to import into Gerrit and try out code review on.
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200115
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800116=== New project from scratch
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200117If you choose to create a new repository from scratch, it's easier for
118you to create a project with an initial commit in it. That way first
119time setup between client and server is easier.
120
121This is done via the SSH port:
122
123----
Andrew Bonventre72eff312015-11-24 13:52:31 -0500124 user@host:~$ ssh -p 29418 user@localhost gerrit create-project demo-project --empty-commit
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200125 user@host:~$
126----
127
David Pursehouse221d4f62012-06-08 17:38:08 +0900128This will create a repository that you can clone to work with.
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200129
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800130=== Already existing project
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200131
132The other alternative is if you already have a git project that you
133want to try out Gerrit on.
David Pursehouse221d4f62012-06-08 17:38:08 +0900134First you have to create the project. This is done via the SSH port:
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200135
136----
Andrew Bonventre72eff312015-11-24 13:52:31 -0500137 user@host:~$ ssh -p 29418 user@localhost gerrit create-project demo-project
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200138 user@host:~$
139----
140
Carlo Marcelo Arenas Belon78df6192012-01-31 02:58:41 -0800141You need to make sure that at least initially your account is granted
142"Create Reference" privileges for the refs/heads/* reference.
143This is done via the web interface in the Admin/Projects/Access page
144that correspond to your project.
145
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200146After that it's time to upload the previous history to the server:
147
148----
149 user@host:~/my-project$ git push ssh://user@localhost:29418/demo-project *:*
Carlo Marcelo Arenas Belon78df6192012-01-31 02:58:41 -0800150 Counting objects: 2011, done.
151 Writing objects: 100% (2011/2011), 456293 bytes, done.
152 Total 2011 (delta 0), reused 0 (delta 0)
153 To ssh://user@localhost:29418/demo-project
154 * [new branch] master -> master
155 user@host:~/my-project$
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200156----
157
David Pursehouse221d4f62012-06-08 17:38:08 +0900158This will create a repository that you can clone to work with.
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200159
160
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800161== My first change
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200162
Carlo Marcelo Arenas Belon78df6192012-01-31 02:58:41 -0800163Download a local clone of the repository and move into it
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200164
165----
Hugo Arèsc4e85f02015-09-25 14:56:06 -0400166 user@host:~$ git clone ssh://user@localhost:29418/demo-project
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200167 Cloning into demo-project...
168 remote: Counting objects: 2, done
169 remote: Finding sources: 100% (2/2)
170 remote: Total 2 (delta 0), reused 0 (delta 0)
Carlo Marcelo Arenas Belon78df6192012-01-31 02:58:41 -0800171 user@host:~$ cd demo-project
172 user@host:~/demo-project$
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200173----
174
175Then make a change to it and upload it as a reviewable change in Gerrit.
176
177----
Carlo Marcelo Arenas Belon78df6192012-01-31 02:58:41 -0800178 user@host:~/demo-project$ date > testfile.txt
179 user@host:~/demo-project$ git add testfile.txt
180 user@host:~/demo-project$ git commit -m "My pretty test commit"
181 [master ff643a5] My pretty test commit
182 1 files changed, 1 insertions(+), 0 deletions(-)
183 create mode 100644 testfile.txt
184 user@host:~/demo-project$
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200185----
186
187Usually when you push to a remote git, you push to the reference
188`'/refs/heads/branch'`, but when working with Gerrit you have to push to a
David Pursehouse221d4f62012-06-08 17:38:08 +0900189virtual branch representing "code review before submission to branch".
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200190This virtual name space is known as /refs/for/<branch>
191
192----
Carlo Marcelo Arenas Belon78df6192012-01-31 02:58:41 -0800193 user@host:~/demo-project$ git push origin HEAD:refs/for/master
194 Counting objects: 4, done.
195 Writing objects: 100% (3/3), 293 bytes, done.
196 Total 3 (delta 0), reused 0 (delta 0)
197 remote:
198 remote: New Changes:
199 remote: http://localhost:8080/1
200 remote:
201 To ssh://user@localhost:29418/demo-project
202 * [new branch] HEAD -> refs/for/master
203 user@host:~/demo-project$
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200204----
205
206You should now be able to access your change by browsing to the http URL
207suggested above, http://localhost:8080/1
208
209
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800210== Quick Installation Complete
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200211
212This covers the scope of getting Gerrit started and your first change uploaded.
David Pursehouse221d4f62012-06-08 17:38:08 +0900213It doesn't give any clue as to how the review workflow works, please read
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200214link:http://source.android.com/submit-patches/workflow[Default Workflow] to
215learn more about the workflow of Gerrit.
216
David Pursehouse221d4f62012-06-08 17:38:08 +0900217To read more on the installation of Gerrit please see link:install.html[the detailed
Fredrik Luthandera75dadc2011-10-28 06:58:18 +0200218installation page].
219
220
221GERRIT
222------
223
224Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700225
226SEARCHBOX
227---------