Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 1 | = Gerrit Code Review: Developer Setup |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 2 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 3 | To build a developer instance, you'll need link:https://bazel.build/[Bazel] to |
| 4 | compile the code. |
David Pursehouse | fec5879 | 2013-05-10 15:34:02 +0100 | [diff] [blame] | 5 | |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 6 | == Git Setup |
| 7 | |
Edwin Kempin | ef1b811 | 2019-10-29 09:27:00 +0100 | [diff] [blame] | 8 | [[clone]] |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 9 | === Getting the Source |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 10 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 11 | Create a new client workspace: |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 12 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 13 | ---- |
David Pursehouse | b964ac1 | 2018-10-12 14:01:39 +0900 | [diff] [blame] | 14 | git clone --recurse-submodules https://gerrit.googlesource.com/gerrit |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 15 | cd gerrit |
| 16 | ---- |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 17 | |
Joerg Zieren | ed45a28 | 2019-05-03 11:47:51 +0200 | [diff] [blame] | 18 | The `--recurse-submodules` option is needed on `git clone` to ensure that the |
| 19 | core plugins, which are included as git submodules, are also cloned. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 20 | |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 21 | === Switching between branches |
| 22 | |
| 23 | When using `git checkout` without `--recurse-submodules` to switch between |
| 24 | branches, submodule revisions are not altered, which can result in: |
| 25 | |
| 26 | * Incorrect or unneeded plugin revisions. |
| 27 | * Missing plugins. |
| 28 | |
| 29 | After you switch branches, ensure that you have the correct versions of |
| 30 | the submodules. |
| 31 | |
| 32 | CAUTION: If you store Eclipse or IntelliJ project files in the Gerrit source |
| 33 | directories, do *_not_* run `git clean -fdx`. Doing so may remove untracked files and damage your project. For more information, see |
| 34 | link:https://git-scm.com/docs/git-clean[git-clean]. |
| 35 | |
| 36 | Run the following: |
| 37 | |
| 38 | ---- |
| 39 | git submodule update |
| 40 | git clean -ffd |
| 41 | ---- |
| 42 | |
Alice Kober-Sotzek | 4b92e04 | 2016-11-25 10:54:30 +0100 | [diff] [blame] | 43 | [[compile_project]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 44 | == Compiling |
David Pursehouse | 6de7ee2 | 2013-05-20 11:08:51 +0900 | [diff] [blame] | 45 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 46 | For details, see <<dev-bazel#,Building with Bazel>>. |
David Pursehouse | d106c8e | 2013-12-13 15:03:02 +0900 | [diff] [blame] | 47 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 48 | |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 49 | == Testing |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 50 | |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 51 | [[tests]] |
| 52 | === Running the acceptance tests |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 53 | |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 54 | Gerrit contains acceptance tests that validate the Gerrit daemon via REST, SSH, |
| 55 | and the Git protocol. |
Urs Wolfer | c0948bd | 2014-04-27 21:16:25 +0200 | [diff] [blame] | 56 | |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 57 | A new review site is created for each test and the Gerrit daemon is |
| 58 | then started on that site. When the test is completed, the Gerrit daemon is |
| 59 | shut down. |
Alice Kober-Sotzek | 4b92e04 | 2016-11-25 10:54:30 +0100 | [diff] [blame] | 60 | |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 61 | For instructions on running the acceptance tests with Bazel, |
| 62 | see <<dev-bazel#tests,Running Unit Tests with Bazel>>. |
David Pursehouse | fec5879 | 2013-05-10 15:34:02 +0100 | [diff] [blame] | 63 | |
Shawn O. Pearce | 461c2cc | 2009-02-25 09:09:31 -0800 | [diff] [blame] | 64 | |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 65 | == Local server |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 66 | |
| 67 | [[init]] |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 68 | === Site Initialization |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 69 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 70 | After you compile the project <<compile_project,(above)>>, run the Gerrit |
| 71 | `init` |
| 72 | command to create a test site: |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 73 | |
Alice Kober-Sotzek | 4b92e04 | 2016-11-25 10:54:30 +0100 | [diff] [blame] | 74 | ---- |
Ben Rohlfs | b65406b | 2019-05-02 10:43:40 +0200 | [diff] [blame] | 75 | export GERRIT_SITE=~/gerrit_testsite |
Alice Kober-Sotzek | 4b92e04 | 2016-11-25 10:54:30 +0100 | [diff] [blame] | 76 | $(bazel info output_base)/external/local_jdk/bin/java \ |
Ben Rohlfs | b65406b | 2019-05-02 10:43:40 +0200 | [diff] [blame] | 77 | -jar bazel-bin/gerrit.war init --batch --dev -d $GERRIT_SITE |
Alice Kober-Sotzek | 4b92e04 | 2016-11-25 10:54:30 +0100 | [diff] [blame] | 78 | ---- |
| 79 | |
| 80 | [[special_bazel_java_version]] |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 81 | NOTE: You must use the same Java version that Bazel used for the build, which |
| 82 | is available at `$(bazel info output_base)/external/local_jdk/bin/java`. |
Alice Kober-Sotzek | 4b92e04 | 2016-11-25 10:54:30 +0100 | [diff] [blame] | 83 | |
Ben Rohlfs | 0f00717 | 2019-04-29 21:41:05 +0200 | [diff] [blame] | 84 | This command takes two parameters: |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 85 | |
Ben Rohlfs | 0f00717 | 2019-04-29 21:41:05 +0200 | [diff] [blame] | 86 | * `--batch` assigns default values to several Gerrit configuration |
| 87 | options. To learn more about these options, see |
| 88 | link:config-gerrit.html[Configuration]. |
| 89 | * `--dev` configures the Gerrit server to use the authentication |
| 90 | option, `DEVELOPMENT_BECOME_ANY_ACCOUNT`, which enables you to |
| 91 | switch between different users to explore how Gerrit works. To learn more |
| 92 | about setting up Gerrit for development, see |
| 93 | link:dev-readme.html[Gerrit Code Review: Developer Setup]. |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 94 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 95 | After initializing the test site, Gerrit starts serving in the background. A |
| 96 | web browser displays the Start page. |
Aaron Gable | 5eab720 | 2016-10-12 11:24:06 -0700 | [diff] [blame] | 97 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 98 | On the Start page, you can: |
| 99 | |
| 100 | . Log in as the account you created during the initialization process. |
| 101 | . Register additional accounts. |
| 102 | . Create projects. |
| 103 | |
| 104 | To shut down the daemon, run: |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 105 | |
| 106 | ---- |
Ben Rohlfs | b65406b | 2019-05-02 10:43:40 +0200 | [diff] [blame] | 107 | $GERRIT_SITE/bin/gerrit.sh stop |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 108 | ---- |
| 109 | |
| 110 | |
Aaron Gable | 5eab720 | 2016-10-12 11:24:06 -0700 | [diff] [blame] | 111 | [[localdev]] |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 112 | === Working with the Local Server |
Aaron Gable | 5eab720 | 2016-10-12 11:24:06 -0700 | [diff] [blame] | 113 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 114 | To create more accounts on your development instance: |
| 115 | |
| 116 | . Click 'become' in the upper right corner. |
| 117 | . Select 'Switch User'. |
| 118 | . Register a new account. |
brohlfs | bdcea6d | 2019-01-22 10:36:23 +0100 | [diff] [blame] | 119 | . link:user-upload.html#ssh[Configure your SSH key]. |
Aaron Gable | 5eab720 | 2016-10-12 11:24:06 -0700 | [diff] [blame] | 120 | |
| 121 | Use the `ssh` protocol to clone from and push to the local server. For |
| 122 | example, to clone a repository that you've created through the admin |
| 123 | interface, run: |
| 124 | |
| 125 | ---- |
| 126 | git clone ssh://username@localhost:29418/projectname |
| 127 | ---- |
| 128 | |
Joerg Zieren | 937d545 | 2019-05-17 10:39:41 +0200 | [diff] [blame] | 129 | To use the `HTTP` protocol, run: |
| 130 | |
| 131 | ---- |
| 132 | git clone http://username@localhost:8080/projectname |
| 133 | ---- |
| 134 | |
| 135 | The default password for user `admin` is `secret`. You can regenerate a |
| 136 | password in the UI under User Settings -- HTTP credentials. The password can be |
| 137 | stored locally to avoid retyping it: |
| 138 | |
| 139 | ---- |
| 140 | git config --global credential.helper store |
| 141 | git pull |
| 142 | ---- |
| 143 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 144 | To create changes as users of Gerrit would, run: |
Aaron Gable | 5eab720 | 2016-10-12 11:24:06 -0700 | [diff] [blame] | 145 | |
| 146 | ---- |
| 147 | git push origin HEAD:refs/for/master |
| 148 | ---- |
| 149 | |
Alice Kober-Sotzek | d9da89f | 2016-11-25 12:02:18 +0100 | [diff] [blame] | 150 | [[run_daemon]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 151 | === Running the Daemon |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 152 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 153 | The daemon can be launched directly from the build area, without |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 154 | copying to the test site: |
| 155 | |
Alice Kober-Sotzek | 4b92e04 | 2016-11-25 10:54:30 +0100 | [diff] [blame] | 156 | ---- |
| 157 | $(bazel info output_base)/external/local_jdk/bin/java \ |
Ben Rohlfs | b65406b | 2019-05-02 10:43:40 +0200 | [diff] [blame] | 158 | -jar bazel-bin/gerrit.war daemon -d $GERRIT_SITE \ |
Han-Wen Nienhuys | 0c93bc8 | 2017-01-19 15:26:42 +0100 | [diff] [blame] | 159 | --console-log |
Alice Kober-Sotzek | 4b92e04 | 2016-11-25 10:54:30 +0100 | [diff] [blame] | 160 | ---- |
| 161 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 162 | NOTE: To learn why using `java -jar` isn't sufficient, see |
| 163 | <<special_bazel_java_version,this explanation>>. |
Alice Kober-Sotzek | 4b92e04 | 2016-11-25 10:54:30 +0100 | [diff] [blame] | 164 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 165 | To debug the Gerrit server of this test site: |
| 166 | |
| 167 | . Open a debug port (such as port 5005). To do so, insert the following code |
| 168 | immediately after `-jar` in the previous command. To learn how to attach |
| 169 | IntelliJ, see <<dev-intellij#remote-debug,Debugging a remote Gerrit server>>. |
Alice Kober-Sotzek | 485a5ff | 2017-03-02 13:20:32 +0100 | [diff] [blame] | 170 | |
| 171 | ---- |
| 172 | -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 |
| 173 | ---- |
| 174 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 175 | === Running the Daemon with Gerrit Inspector |
Marcin Cieślak | ed612fb | 2012-04-17 16:24:34 +0000 | [diff] [blame] | 176 | |
| 177 | link:dev-inspector.html[Gerrit Inspector] is an interactive scriptable |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 178 | environment you can use to inspect and modify the internal state of the system. |
Marcin Cieślak | ed612fb | 2012-04-17 16:24:34 +0000 | [diff] [blame] | 179 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 180 | Gerrit Inspector appears on the system console whenever the system starts. |
| 181 | Leaving the Inspector shuts down the Gerrit instance. |
Marcin Cieślak | ed612fb | 2012-04-17 16:24:34 +0000 | [diff] [blame] | 182 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 183 | To troubleshoot, the Inspector enables interactive work as well as running of |
| 184 | Python scripts. |
Marcin Cieślak | ed612fb | 2012-04-17 16:24:34 +0000 | [diff] [blame] | 185 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 186 | To start the Inspector, add the '-s' option to the daemon start command: |
Marcin Cieślak | ed612fb | 2012-04-17 16:24:34 +0000 | [diff] [blame] | 187 | |
Alice Kober-Sotzek | 4b92e04 | 2016-11-25 10:54:30 +0100 | [diff] [blame] | 188 | ---- |
| 189 | $(bazel info output_base)/external/local_jdk/bin/java \ |
Ben Rohlfs | b65406b | 2019-05-02 10:43:40 +0200 | [diff] [blame] | 190 | -jar bazel-bin/gerrit.war daemon -d $GERRIT_SITE -s |
Alice Kober-Sotzek | 4b92e04 | 2016-11-25 10:54:30 +0100 | [diff] [blame] | 191 | ---- |
| 192 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 193 | NOTE: To learn why using `java -jar` isn't sufficient, see |
| 194 | <<special_bazel_java_version,this explanation>>. |
Alice Kober-Sotzek | 4b92e04 | 2016-11-25 10:54:30 +0100 | [diff] [blame] | 195 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 196 | Inspector examines Java libraries, loads the initialization scripts, and |
| 197 | starts a command line prompt on the console: |
Marcin Cieślak | ed612fb | 2012-04-17 16:24:34 +0000 | [diff] [blame] | 198 | |
| 199 | ---- |
| 200 | Welcome to the Gerrit Inspector |
| 201 | Enter help() to see the above again, EOF to quit and stop Gerrit |
| 202 | Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06) |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 203 | [OpenJDK 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0 running for |
| 204 | Gerrit 2.3-rc0-163-g01967ef |
Marcin Cieślak | ed612fb | 2012-04-17 16:24:34 +0000 | [diff] [blame] | 205 | >>> |
| 206 | ---- |
| 207 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 208 | When the Inspector is enabled, you can use Gerrit as usual and all |
| 209 | interfaces (including HTTP and SSH) are available. |
Marcin Cieślak | ed612fb | 2012-04-17 16:24:34 +0000 | [diff] [blame] | 210 | |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 211 | CAUTION: When using the Inspector, be careful not to modify the internal state |
| 212 | of the system. |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 213 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 214 | |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 215 | == Setup for backend developers |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 216 | |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 217 | === Configuring Eclipse |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 218 | |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 219 | To use the Eclipse IDE for development, see |
| 220 | link:dev-eclipse.html[Eclipse Setup]. |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 221 | |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 222 | To configure the Eclipse workspace with Bazel, see |
| 223 | link:dev-bazel.html#eclipse[Eclipse integration with Bazel]. |
Janet Davies | 0c1a621 | 2018-05-09 15:18:57 -0700 | [diff] [blame] | 224 | |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 225 | === Configuring IntelliJ IDEA |
Shawn Pearce | d07a622 | 2013-03-21 00:11:45 -0700 | [diff] [blame] | 226 | |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 227 | See <<dev-intellij#,IntelliJ Setup>> for details. |
| 228 | |
Alice Kober-Sotzek | 79290dc | 2019-05-07 19:26:18 +0200 | [diff] [blame] | 229 | == Setup for frontend developers |
| 230 | See link:https://gerrit.googlesource.com/gerrit/+/master/polygerrit-ui/README.md[Frontend Developer Setup]. |
| 231 | |
Shawn Pearce | d07a622 | 2013-03-21 00:11:45 -0700 | [diff] [blame] | 232 | |
Shawn O. Pearce | 5500e69 | 2009-05-28 15:55:01 -0700 | [diff] [blame] | 233 | GERRIT |
| 234 | ------ |
| 235 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 236 | |
| 237 | SEARCHBOX |
| 238 | --------- |