Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 1 | = Gerrit Code Review - Quick get started guide |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 2 | |
| 3 | **** |
| 4 | This guide was made with the impatient in mind, ready to try out Gerrit on their |
| 5 | own server but not prepared to make the full installation procedure yet. |
| 6 | |
| 7 | Explanation is sparse and you should not use a server installed this way in a |
| 8 | live setup, this is made with proof of concept activities in mind. |
| 9 | |
| 10 | It is presumed you install it on a Unix based server such as any of the Linux |
| 11 | flavors or BSD. |
| 12 | |
| 13 | It's also presumed that you have access to an OpenID enabled email address. |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 14 | Examples of OpenID enable email providers are Gmail, Yahoo! Mail and Hotmail. |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 15 | It's also possible to register a custom email address with OpenID, but that is |
| 16 | outside the scope of this quick installation guide. For testing purposes one of |
| 17 | the above providers should be fine. Please note that network access to the |
| 18 | OpenID provider you choose is necessary for both you and your Gerrit instance. |
| 19 | **** |
| 20 | |
| 21 | |
| 22 | [[requirements]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 23 | == Requirements |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 24 | |
| 25 | Most distributions come with Java today. Do you already have Java installed? |
| 26 | |
| 27 | ---- |
| 28 | $ java -version |
David Ostrovsky | 3931c16 | 2014-06-15 00:33:40 +0200 | [diff] [blame] | 29 | 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 Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 32 | ---- |
| 33 | |
| 34 | If Java isn't installed, get it: |
| 35 | |
David Pursehouse | 7b40944 | 2016-11-15 12:11:21 -0800 | [diff] [blame] | 36 | * JRE, minimum version 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html[Download] |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 37 | |
| 38 | |
| 39 | [[user]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 40 | == Create a user to host the Gerrit service |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 41 | |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 42 | We will run the service as a non-privileged user on your system. |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 43 | First create the user and then become the user: |
| 44 | |
| 45 | ---- |
Carlo Marcelo Arenas Belon | 78df619 | 2012-01-31 02:58:41 -0800 | [diff] [blame] | 46 | $ sudo adduser gerrit2 |
| 47 | $ sudo su gerrit2 |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 48 | ---- |
| 49 | |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 50 | If you don't have root privileges you could skip this step and run Gerrit |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 51 | as your own user as well. |
| 52 | |
| 53 | |
| 54 | [[download]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 55 | == Download Gerrit |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 56 | |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 57 | It's time to download the archive that contains the Gerrit web and ssh service. |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 58 | |
| 59 | You can choose from different versions to download from here: |
| 60 | |
Shawn Pearce | 6d7ebc6 | 2015-06-12 16:34:42 -0700 | [diff] [blame] | 61 | * https://www.gerritcodereview.com/download/index.html[A list of releases available] |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 62 | |
Carlo Marcelo Arenas Belon | 78df619 | 2012-01-31 02:58:41 -0800 | [diff] [blame] | 63 | This tutorial is based on version 2.2.2, and you can download that from this link |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 64 | |
Shawn Pearce | 6d7ebc6 | 2015-06-12 16:34:42 -0700 | [diff] [blame] | 65 | * https://www.gerritcodereview.com/download/gerrit-2.2.2.war[Link to the 2.2.2 war archive] |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 66 | |
| 67 | |
| 68 | [[initialization]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 69 | == Initialize the Site |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 70 | |
| 71 | It'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 Belon | 78df619 | 2012-01-31 02:58:41 -0800 | [diff] [blame] | 74 | 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 Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 80 | ---- |
| 81 | |
| 82 | When the init is complete, you can review your settings in the |
| 83 | file `'$site_path/etc/gerrit.config'`. |
| 84 | |
David Pursehouse | 19f067e | 2012-06-14 13:40:09 +0900 | [diff] [blame] | 85 | Note that initialization also starts the server. If any settings changes are |
| 86 | made, the server must be restarted before they will take effect. |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 87 | |
| 88 | ---- |
David Pursehouse | 19f067e | 2012-06-14 13:40:09 +0900 | [diff] [blame] | 89 | gerrit2@host:~$ ~/gerrit_testsite/bin/gerrit.sh restart |
| 90 | Stopping Gerrit Code Review: OK |
| 91 | Starting Gerrit Code Review: OK |
Carlo Marcelo Arenas Belon | 78df619 | 2012-01-31 02:58:41 -0800 | [diff] [blame] | 92 | gerrit2@host:~$ |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 93 | ---- |
David Pursehouse | 19f067e | 2012-06-14 13:40:09 +0900 | [diff] [blame] | 94 | |
| 95 | The server can be also stopped and started by passing the `stop` and `start` |
| 96 | commands 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 Huntley | dd21001 | 2012-07-30 13:53:45 -0400 | [diff] [blame] | 107 | include::config-login-register.txt[] |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 108 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 109 | == Project creation |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 110 | |
| 111 | Your base Gerrit server is now running and you have a user that's ready |
| 112 | to interact with it. You now have two options, either you create a new |
| 113 | test project to work with or you already have a git with history that |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 114 | you would like to import into Gerrit and try out code review on. |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 115 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 116 | === New project from scratch |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 117 | If you choose to create a new repository from scratch, it's easier for |
| 118 | you to create a project with an initial commit in it. That way first |
| 119 | time setup between client and server is easier. |
| 120 | |
| 121 | This is done via the SSH port: |
| 122 | |
| 123 | ---- |
Andrew Bonventre | 72eff31 | 2015-11-24 13:52:31 -0500 | [diff] [blame] | 124 | user@host:~$ ssh -p 29418 user@localhost gerrit create-project demo-project --empty-commit |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 125 | user@host:~$ |
| 126 | ---- |
| 127 | |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 128 | This will create a repository that you can clone to work with. |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 129 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 130 | === Already existing project |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 131 | |
| 132 | The other alternative is if you already have a git project that you |
| 133 | want to try out Gerrit on. |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 134 | First you have to create the project. This is done via the SSH port: |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 135 | |
| 136 | ---- |
Andrew Bonventre | 72eff31 | 2015-11-24 13:52:31 -0500 | [diff] [blame] | 137 | user@host:~$ ssh -p 29418 user@localhost gerrit create-project demo-project |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 138 | user@host:~$ |
| 139 | ---- |
| 140 | |
Carlo Marcelo Arenas Belon | 78df619 | 2012-01-31 02:58:41 -0800 | [diff] [blame] | 141 | You need to make sure that at least initially your account is granted |
| 142 | "Create Reference" privileges for the refs/heads/* reference. |
| 143 | This is done via the web interface in the Admin/Projects/Access page |
| 144 | that correspond to your project. |
| 145 | |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 146 | After 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 Belon | 78df619 | 2012-01-31 02:58:41 -0800 | [diff] [blame] | 150 | 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 Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 156 | ---- |
| 157 | |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 158 | This will create a repository that you can clone to work with. |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 159 | |
| 160 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 161 | == My first change |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 162 | |
Carlo Marcelo Arenas Belon | 78df619 | 2012-01-31 02:58:41 -0800 | [diff] [blame] | 163 | Download a local clone of the repository and move into it |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 164 | |
| 165 | ---- |
Hugo Arès | c4e85f0 | 2015-09-25 14:56:06 -0400 | [diff] [blame] | 166 | user@host:~$ git clone ssh://user@localhost:29418/demo-project |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 167 | 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 Belon | 78df619 | 2012-01-31 02:58:41 -0800 | [diff] [blame] | 171 | user@host:~$ cd demo-project |
| 172 | user@host:~/demo-project$ |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 173 | ---- |
| 174 | |
| 175 | Then make a change to it and upload it as a reviewable change in Gerrit. |
| 176 | |
| 177 | ---- |
Carlo Marcelo Arenas Belon | 78df619 | 2012-01-31 02:58:41 -0800 | [diff] [blame] | 178 | 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 Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 185 | ---- |
| 186 | |
| 187 | Usually 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 Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 189 | virtual branch representing "code review before submission to branch". |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 190 | This virtual name space is known as /refs/for/<branch> |
| 191 | |
| 192 | ---- |
Carlo Marcelo Arenas Belon | 78df619 | 2012-01-31 02:58:41 -0800 | [diff] [blame] | 193 | 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 Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 204 | ---- |
| 205 | |
| 206 | You should now be able to access your change by browsing to the http URL |
| 207 | suggested above, http://localhost:8080/1 |
| 208 | |
| 209 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 210 | == Quick Installation Complete |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 211 | |
| 212 | This covers the scope of getting Gerrit started and your first change uploaded. |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 213 | It doesn't give any clue as to how the review workflow works, please read |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 214 | link:http://source.android.com/submit-patches/workflow[Default Workflow] to |
| 215 | learn more about the workflow of Gerrit. |
| 216 | |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 217 | To read more on the installation of Gerrit please see link:install.html[the detailed |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 218 | installation page]. |
| 219 | |
| 220 | |
| 221 | GERRIT |
| 222 | ------ |
| 223 | |
| 224 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 225 | |
| 226 | SEARCHBOX |
| 227 | --------- |