James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 1 | :title: Gerrit Driver |
| 2 | |
| 3 | Gerrit |
| 4 | ====== |
| 5 | |
| 6 | `Gerrit`_ is a code review system. The Gerrit driver supports |
| 7 | sources, triggers, and reporters. |
| 8 | |
| 9 | .. _Gerrit: https://www.gerritcodereview.com/ |
| 10 | |
| 11 | Zuul will need access to a Gerrit user. |
| 12 | |
| 13 | Create an SSH keypair for Zuul to use if there isn't one already, and |
| 14 | create a Gerrit user with that key:: |
| 15 | |
| 16 | cat ~/id_rsa.pub | ssh -p29418 review.example.com gerrit create-account --ssh-key - --full-name Zuul zuul |
| 17 | |
| 18 | Give that user whatever permissions will be needed on the projects you |
| 19 | want Zuul to report on. For instance, you may want to grant |
| 20 | ``Verified +/-1`` and ``Submit`` to the user. Additional categories |
| 21 | or values may be added to Gerrit. Zuul is very flexible and can take |
| 22 | advantage of those. |
| 23 | |
| 24 | Connection Configuration |
| 25 | ------------------------ |
| 26 | |
| 27 | The supported options in zuul.conf connections are: |
| 28 | |
| 29 | **driver=gerrit** |
| 30 | |
| 31 | **server** |
| 32 | FQDN of Gerrit server. |
| 33 | ``server=review.example.com`` |
| 34 | |
| 35 | **canonical_hostname** |
| 36 | The canonical hostname associated with the git repos on the Gerrit |
| 37 | server. Defaults to the value of **server**. This is used to |
| 38 | identify repos from this connection by name and in preparing repos |
| 39 | on the filesystem for use by jobs. |
| 40 | ``canonical_hostname=git.example.com`` |
| 41 | |
| 42 | **port** |
| 43 | Optional: Gerrit server port. |
| 44 | ``port=29418`` |
| 45 | |
| 46 | **baseurl** |
| 47 | Optional: path to Gerrit web interface. Defaults to ``https://<value |
| 48 | of server>/``. ``baseurl=https://review.example.com/review_site/`` |
| 49 | |
| 50 | **user** |
| 51 | User name to use when logging into above server via ssh. |
| 52 | ``user=zuul`` |
| 53 | |
| 54 | **sshkey** |
| 55 | Path to SSH key to use when logging into above server. |
| 56 | ``sshkey=/home/zuul/.ssh/id_rsa`` |
| 57 | |
| 58 | **keepalive** |
| 59 | Optional: Keepalive timeout, 0 means no keepalive. |
| 60 | ``keepalive=60`` |
| 61 | |
| 62 | Trigger Configuration |
| 63 | --------------------- |
| 64 | |
| 65 | Zuul works with standard versions of Gerrit by invoking the ``gerrit |
| 66 | stream-events`` command over an SSH connection. It also reports back |
| 67 | to Gerrit using SSH. |
| 68 | |
| 69 | If using Gerrit 2.7 or later, make sure the user is a member of a group |
| 70 | that is granted the ``Stream Events`` permission, otherwise it will not |
| 71 | be able to invoke the ``gerrit stream-events`` command over SSH. |
| 72 | |
| 73 | The supported pipeline trigger options are: |
| 74 | |
| 75 | **event** |
| 76 | The event name from gerrit. Examples: ``patchset-created``, |
| 77 | ``comment-added``, ``ref-updated``. This field is treated as a |
| 78 | regular expression. |
| 79 | |
| 80 | **branch** |
| 81 | The branch associated with the event. Example: ``master``. This |
| 82 | field is treated as a regular expression, and multiple branches may |
| 83 | be listed. |
| 84 | |
| 85 | **ref** |
| 86 | On ref-updated events, the branch parameter is not used, instead the |
| 87 | ref is provided. Currently Gerrit has the somewhat idiosyncratic |
| 88 | behavior of specifying bare refs for branch names (e.g., ``master``), |
| 89 | but full ref names for other kinds of refs (e.g., ``refs/tags/foo``). |
| 90 | Zuul matches what you put here exactly against what Gerrit |
| 91 | provides. This field is treated as a regular expression, and |
| 92 | multiple refs may be listed. |
| 93 | |
| 94 | **ignore-deletes** |
| 95 | When a branch is deleted, a ref-updated event is emitted with a newrev |
| 96 | of all zeros specified. The ``ignore-deletes`` field is a boolean value |
| 97 | that describes whether or not these newrevs trigger ref-updated events. |
| 98 | The default is True, which will not trigger ref-updated events. |
| 99 | |
| 100 | **approval** |
| 101 | This is only used for ``comment-added`` events. It only matches if |
| 102 | the event has a matching approval associated with it. Example: |
| 103 | ``code-review: 2`` matches a ``+2`` vote on the code review category. |
| 104 | Multiple approvals may be listed. |
| 105 | |
| 106 | **email** |
| 107 | This is used for any event. It takes a regex applied on the performer |
| 108 | email, i.e. Gerrit account email address. If you want to specify |
| 109 | several email filters, you must use a YAML list. Make sure to use non |
| 110 | greedy matchers and to escapes dots! |
| 111 | Example: ``email: ^.*?@example\.org$``. |
| 112 | |
| 113 | **email_filter** (deprecated) |
| 114 | A deprecated alternate spelling of *email*. Only one of *email* or |
| 115 | *email_filter* should be used. |
| 116 | |
| 117 | **username** |
| 118 | This is used for any event. It takes a regex applied on the performer |
| 119 | username, i.e. Gerrit account name. If you want to specify several |
| 120 | username filters, you must use a YAML list. Make sure to use non greedy |
| 121 | matchers and to escapes dots! |
| 122 | Example: ``username: ^jenkins$``. |
| 123 | |
| 124 | **username_filter** (deprecated) |
| 125 | A deprecated alternate spelling of *username*. Only one of *username* or |
| 126 | *username_filter* should be used. |
| 127 | |
| 128 | **comment** |
| 129 | This is only used for ``comment-added`` events. It accepts a list of |
| 130 | regexes that are searched for in the comment string. If any of these |
| 131 | regexes matches a portion of the comment string the trigger is |
| 132 | matched. ``comment: retrigger`` will match when comments |
| 133 | containing 'retrigger' somewhere in the comment text are added to a |
| 134 | change. |
| 135 | |
| 136 | **comment_filter** (deprecated) |
| 137 | A deprecated alternate spelling of *comment*. Only one of *comment* or |
| 138 | *comment_filter* should be used. |
| 139 | |
| 140 | *require-approval* |
| 141 | This may be used for any event. It requires that a certain kind |
| 142 | of approval be present for the current patchset of the change (the |
| 143 | approval could be added by the event in question). It follows the |
| 144 | same syntax as the :ref:`"approval" pipeline requirement |
| 145 | <pipeline-require-approval>`. For each specified criteria there must |
| 146 | exist a matching approval. |
| 147 | |
| 148 | *reject-approval* |
| 149 | This takes a list of approvals in the same format as |
| 150 | *require-approval* but will fail to enter the pipeline if there is |
| 151 | a matching approval. |
| 152 | |
| 153 | Reporter Configuration |
| 154 | ---------------------- |
| 155 | |
| 156 | Zuul works with standard versions of Gerrit by invoking the |
| 157 | ``gerrit`` command over an SSH connection. It reports back to |
| 158 | Gerrit using SSH. |
| 159 | |
| 160 | The dictionary passed to the Gerrit reporter is used for ``gerrit |
| 161 | review`` arguments, with the boolean value of ``true`` simply |
| 162 | indicating that the argument should be present without following it |
| 163 | with a value. For example, ``verified: 1`` becomes ``gerrit review |
| 164 | --verified 1`` and ``submit: true`` becomes ``gerrit review |
| 165 | --submit``. |
| 166 | |
| 167 | A :ref:`connection<connections>` that uses the gerrit driver must be |
| 168 | supplied to the trigger. |