James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 1 | :title: Triggers |
| 2 | |
| 3 | Triggers |
| 4 | ======== |
| 5 | |
| 6 | The process of merging a change starts with proposing a change to be |
Gregory Haynes | 4fc1254 | 2015-04-22 20:38:06 -0700 | [diff] [blame] | 7 | merged. Zuul supports Gerrit and GitHub as triggering systems. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 8 | Zuul's design is modular, so alternate triggering and reporting |
James E. Blair | 63bb0ef | 2013-07-29 17:14:51 -0700 | [diff] [blame] | 9 | systems can be supported. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 10 | |
| 11 | Gerrit |
| 12 | ------ |
| 13 | |
| 14 | Zuul works with standard versions of Gerrit by invoking the ``gerrit |
| 15 | stream-events`` command over an SSH connection. It also reports back |
| 16 | to Gerrit using SSH. |
| 17 | |
David Pursehouse | 78556f7 | 2014-11-04 18:44:36 +0900 | [diff] [blame] | 18 | If using Gerrit 2.7 or later, make sure the user is a member of a group |
| 19 | that is granted the ``Stream Events`` permission, otherwise it will not |
| 20 | be able to invoke the ``gerrit stream-events`` command over SSH. |
| 21 | |
Joshua Hesketh | fe485c6 | 2015-08-11 23:42:34 +1000 | [diff] [blame] | 22 | A connection name with the gerrit driver can take multiple events with |
| 23 | the following options. |
| 24 | |
| 25 | **event** |
| 26 | The event name from gerrit. Examples: ``patchset-created``, |
| 27 | ``comment-added``, ``ref-updated``. This field is treated as a |
| 28 | regular expression. |
| 29 | |
| 30 | **branch** |
| 31 | The branch associated with the event. Example: ``master``. This |
| 32 | field is treated as a regular expression, and multiple branches may |
| 33 | be listed. |
| 34 | |
| 35 | **ref** |
| 36 | On ref-updated events, the branch parameter is not used, instead the |
| 37 | ref is provided. Currently Gerrit has the somewhat idiosyncratic |
| 38 | behavior of specifying bare refs for branch names (e.g., ``master``), |
| 39 | but full ref names for other kinds of refs (e.g., ``refs/tags/foo``). |
| 40 | Zuul matches what you put here exactly against what Gerrit |
| 41 | provides. This field is treated as a regular expression, and |
| 42 | multiple refs may be listed. |
| 43 | |
| 44 | **ignore-deletes** |
| 45 | When a branch is deleted, a ref-updated event is emitted with a newrev |
| 46 | of all zeros specified. The ``ignore-deletes`` field is a boolean value |
| 47 | that describes whether or not these newrevs trigger ref-updated events. |
| 48 | The default is True, which will not trigger ref-updated events. |
| 49 | |
| 50 | **approval** |
| 51 | This is only used for ``comment-added`` events. It only matches if |
| 52 | the event has a matching approval associated with it. Example: |
| 53 | ``code-review: 2`` matches a ``+2`` vote on the code review category. |
| 54 | Multiple approvals may be listed. |
| 55 | |
| 56 | **email** |
| 57 | This is used for any event. It takes a regex applied on the performer |
| 58 | email, i.e. Gerrit account email address. If you want to specify |
| 59 | several email filters, you must use a YAML list. Make sure to use non |
| 60 | greedy matchers and to escapes dots! |
| 61 | Example: ``email: ^.*?@example\.org$``. |
| 62 | |
| 63 | **email_filter** (deprecated) |
| 64 | A deprecated alternate spelling of *email*. Only one of *email* or |
| 65 | *email_filter* should be used. |
| 66 | |
| 67 | **username** |
| 68 | This is used for any event. It takes a regex applied on the performer |
| 69 | username, i.e. Gerrit account name. If you want to specify several |
| 70 | username filters, you must use a YAML list. Make sure to use non greedy |
| 71 | matchers and to escapes dots! |
| 72 | Example: ``username: ^jenkins$``. |
| 73 | |
| 74 | **username_filter** (deprecated) |
| 75 | A deprecated alternate spelling of *username*. Only one of *username* or |
| 76 | *username_filter* should be used. |
| 77 | |
| 78 | **comment** |
| 79 | This is only used for ``comment-added`` events. It accepts a list of |
| 80 | regexes that are searched for in the comment string. If any of these |
| 81 | regexes matches a portion of the comment string the trigger is |
| 82 | matched. ``comment: retrigger`` will match when comments |
| 83 | containing 'retrigger' somewhere in the comment text are added to a |
| 84 | change. |
| 85 | |
| 86 | **comment_filter** (deprecated) |
| 87 | A deprecated alternate spelling of *comment*. Only one of *comment* or |
| 88 | *comment_filter* should be used. |
| 89 | |
| 90 | *require-approval* |
| 91 | This may be used for any event. It requires that a certain kind |
| 92 | of approval be present for the current patchset of the change (the |
| 93 | approval could be added by the event in question). It follows the |
| 94 | same syntax as the :ref:`"approval" pipeline requirement |
| 95 | <pipeline-require-approval>`. For each specified criteria there must |
| 96 | exist a matching approval. |
| 97 | |
| 98 | *reject-approval* |
| 99 | This takes a list of approvals in the same format as |
| 100 | *require-approval* but will fail to enter the pipeline if there is |
| 101 | a matching approval. |
| 102 | |
Gregory Haynes | 4fc1254 | 2015-04-22 20:38:06 -0700 | [diff] [blame] | 103 | GitHub |
| 104 | ------ |
| 105 | |
| 106 | Github webhook events can be configured as triggers. |
| 107 | |
| 108 | A connection name with the github driver can take multiple events with the |
| 109 | following options. |
| 110 | |
| 111 | **event** |
| 112 | The pull request event from github. A ``pull_request`` event will |
| 113 | have associated action(s) to trigger from. The supported actions are: |
| 114 | |
| 115 | *opened* - pull request opened |
| 116 | |
| 117 | *changed* - pull request synchronized |
| 118 | |
| 119 | *closed* - pull request closed |
| 120 | |
| 121 | *reopened* - pull request reopened |
| 122 | |
Wayne | 1a78c61 | 2015-06-11 17:14:13 -0700 | [diff] [blame^] | 123 | Additionally a ``push`` event can be configured, with an |
| 124 | associated ``ref`` represented as a regex to match branches or tags. |
| 125 | |
Gregory Haynes | 4fc1254 | 2015-04-22 20:38:06 -0700 | [diff] [blame] | 126 | GitHub Configuration |
| 127 | ~~~~~~~~~~~~~~~~~~~~ |
| 128 | |
| 129 | Configure GitHub `webhook events |
| 130 | <https://developer.github.com/webhooks/creating/>`_. |
| 131 | |
| 132 | Set *Payload URL* to |
| 133 | ``http://<zuul-hostname>/connection/<connection-name>/payload``. |
| 134 | |
| 135 | Set *Content Type* to ``application/json``. |
| 136 | |
| 137 | Select *Events* you are interested in. See above for the supported events. |
Joshua Hesketh | fe485c6 | 2015-08-11 23:42:34 +1000 | [diff] [blame] | 138 | |
James E. Blair | 63bb0ef | 2013-07-29 17:14:51 -0700 | [diff] [blame] | 139 | Timer |
| 140 | ----- |
| 141 | |
| 142 | A simple timer trigger is available as well. It supports triggering |
| 143 | jobs in a pipeline based on cron-style time instructions. |
James E. Blair | c494d54 | 2014-08-06 09:23:52 -0700 | [diff] [blame] | 144 | |
Joshua Hesketh | fe485c6 | 2015-08-11 23:42:34 +1000 | [diff] [blame] | 145 | Timers don't require a special connection or driver. Instead they can |
| 146 | be used by listing **timer** as the trigger. |
| 147 | |
| 148 | This trigger will run based on a cron-style time specification. |
| 149 | It will enqueue an event into its pipeline for every project |
| 150 | defined in the configuration. Any job associated with the |
| 151 | pipeline will run in response to that event. |
| 152 | |
| 153 | **time** |
| 154 | The time specification in cron syntax. Only the 5 part syntax is |
| 155 | supported, not the symbolic names. Example: ``0 0 * * *`` runs |
| 156 | at midnight. |
| 157 | |
James E. Blair | c494d54 | 2014-08-06 09:23:52 -0700 | [diff] [blame] | 158 | Zuul |
| 159 | ---- |
| 160 | |
| 161 | The Zuul trigger generates events based on internal actions in Zuul. |
Joshua Hesketh | fe485c6 | 2015-08-11 23:42:34 +1000 | [diff] [blame] | 162 | Multiple events may be listed. |
| 163 | |
| 164 | Zuul events don't require a special connection or driver. Instead they |
| 165 | can be used by listing **zuul** as the trigger. |
| 166 | |
| 167 | **event** |
| 168 | The event name. Currently supported: |
| 169 | |
| 170 | *project-change-merged* when Zuul merges a change to a project, |
| 171 | it generates this event for every open change in the project. |
| 172 | |
| 173 | *parent-change-enqueued* when Zuul enqueues a change into any |
| 174 | pipeline, it generates this event for every child of that |
| 175 | change. |
| 176 | |
| 177 | **pipeline** |
| 178 | Only available for ``parent-change-enqueued`` events. This is the |
| 179 | name of the pipeline in which the parent change was enqueued. |
| 180 | |
| 181 | *require-approval* |
| 182 | This may be used for any event. It requires that a certain kind |
| 183 | of approval be present for the current patchset of the change (the |
| 184 | approval could be added by the event in question). It follows the |
| 185 | same syntax as the :ref:`"approval" pipeline requirement |
| 186 | <pipeline-require-approval>`. For each specified criteria there must |
| 187 | exist a matching approval. |
| 188 | |
| 189 | *reject-approval* |
| 190 | This takes a list of approvals in the same format as |
| 191 | *require-approval* but will fail to enter the pipeline if there is |
Gregory Haynes | 4fc1254 | 2015-04-22 20:38:06 -0700 | [diff] [blame] | 192 | a matching approval. |