blob: 41a56a0fde9aa5be2b323323187dfe35b7e780f2 [file] [log] [blame]
James E. Blaircdd00072012-06-08 19:17:28 -07001:title: Triggers
2
3Triggers
4========
5
6The process of merging a change starts with proposing a change to be
Gregory Haynes4fc12542015-04-22 20:38:06 -07007merged. Zuul supports Gerrit and GitHub as triggering systems.
James E. Blaircdd00072012-06-08 19:17:28 -07008Zuul's design is modular, so alternate triggering and reporting
James E. Blair63bb0ef2013-07-29 17:14:51 -07009systems can be supported.
James E. Blaircdd00072012-06-08 19:17:28 -070010
11Gerrit
12------
13
14Zuul works with standard versions of Gerrit by invoking the ``gerrit
15stream-events`` command over an SSH connection. It also reports back
16to Gerrit using SSH.
17
David Pursehouse78556f72014-11-04 18:44:36 +090018If using Gerrit 2.7 or later, make sure the user is a member of a group
19that is granted the ``Stream Events`` permission, otherwise it will not
20be able to invoke the ``gerrit stream-events`` command over SSH.
21
Joshua Heskethfe485c62015-08-11 23:42:34 +100022A connection name with the gerrit driver can take multiple events with
23the 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 Haynes4fc12542015-04-22 20:38:06 -0700103GitHub
104------
105
106Github webhook events can be configured as triggers.
107
108A connection name with the github driver can take multiple events with the
109following options.
110
111 **event**
Jesse Keating5c05a9f2017-01-12 14:44:58 -0800112 The event from github. Supported events are ``pull_request``,
113 ``pull_request_review``, and ``push``.
114
115 A ``pull_request`` event will
Gregory Haynes4fc12542015-04-22 20:38:06 -0700116 have associated action(s) to trigger from. The supported actions are:
117
118 *opened* - pull request opened
119
120 *changed* - pull request synchronized
121
122 *closed* - pull request closed
123
124 *reopened* - pull request reopened
125
Jan Hrubanc7ab1602015-10-14 15:29:33 +0200126 *comment* - comment added on pull request
127
Jan Hruban16ad31f2015-11-07 14:39:07 +0100128 *labeled* - label added on pull request
129
130 *unlabeled* - label removed from pull request
131
Jesse Keating5c05a9f2017-01-12 14:44:58 -0800132 *review* - review added on pull request
133
Jan Hruban16ad31f2015-11-07 14:39:07 +0100134 *push* - head reference updated (pushed to branch)
135
Adam Gandelman8c6eeb52017-01-23 16:31:06 -0800136 *status* - status set on commit
137
Jesse Keating5c05a9f2017-01-12 14:44:58 -0800138 A ``pull_request_review`` event will
139 have associated action(s) to trigger from. The supported actions are:
140
141 *submitted* - pull request review added
142
143 *dismissed* - pull request review removed
144
Jan Hruband4edee82015-12-16 12:49:51 +0100145 **branch**
146 The branch associated with the event. Example: ``master``. This
147 field is treated as a regular expression, and multiple branches may
Jesse Keating5c05a9f2017-01-12 14:44:58 -0800148 be listed. Used for ``pull_request`` and ``pull_request_review`` events.
Jan Hruband4edee82015-12-16 12:49:51 +0100149
Jan Hrubanc7ab1602015-10-14 15:29:33 +0200150 **comment**
Jesse Keating5c05a9f2017-01-12 14:44:58 -0800151 This is only used for ``pull_request`` ``comment`` actions. It accepts a
152 list of regexes that are searched for in the comment string. If any of these
Jan Hrubanc7ab1602015-10-14 15:29:33 +0200153 regexes matches a portion of the comment string the trigger is matched.
154 ``comment: retrigger`` will match when comments containing 'retrigger'
155 somewhere in the comment text are added to a pull request.
156
Jan Hruban16ad31f2015-11-07 14:39:07 +0100157 **label**
Jesse Keating5c05a9f2017-01-12 14:44:58 -0800158 This is only used for ``labeled`` and ``unlabeled`` ``pull_request`` actions.
159 It accepts a list of strings each of which matches the label name in the
160 event literally. ``label: recheck`` will match a ``labeled`` action when
161 pull request is labeled with a ``recheck`` label. ``label: 'do not test'``
162 will match a ``unlabeled`` action when a label with name ``do not test`` is
163 removed from the pull request.
Jan Hruban16ad31f2015-11-07 14:39:07 +0100164
Jesse Keating5c05a9f2017-01-12 14:44:58 -0800165 **state**
166 This is only used for ``pull_request_review`` events. It accepts a list of
167 strings each of which is matched to the review state, which can be one of
168 ``approved``, ``comment``, or ``request_changes``.
169
Adam Gandelman8c6eeb52017-01-23 16:31:06 -0800170 **status**
171 This is only used for ``status`` actions. It accepts a list of strings each of
172 which matches the user setting the status, the status context, and the status
173 itself in the format of ``user:context:status``. For example,
174 ``zuul_github_ci_bot:check_pipeline:success``.
175
Jesse Keating5c05a9f2017-01-12 14:44:58 -0800176 **ref**
177 This is only used for ``push`` events. This field is treated as a regular
178 expression and multiple refs may be listed. Github always sends full ref
179 name, eg. ``refs/tags/bar`` and this string is matched against the regexp.
Wayne1a78c612015-06-11 17:14:13 -0700180
Gregory Haynes4fc12542015-04-22 20:38:06 -0700181GitHub Configuration
182~~~~~~~~~~~~~~~~~~~~
183
184Configure GitHub `webhook events
185<https://developer.github.com/webhooks/creating/>`_.
186
187Set *Payload URL* to
188``http://<zuul-hostname>/connection/<connection-name>/payload``.
189
190Set *Content Type* to ``application/json``.
191
192Select *Events* you are interested in. See above for the supported events.
Joshua Heskethfe485c62015-08-11 23:42:34 +1000193
James E. Blair63bb0ef2013-07-29 17:14:51 -0700194Timer
195-----
196
197A simple timer trigger is available as well. It supports triggering
198jobs in a pipeline based on cron-style time instructions.
James E. Blairc494d542014-08-06 09:23:52 -0700199
Joshua Heskethfe485c62015-08-11 23:42:34 +1000200Timers don't require a special connection or driver. Instead they can
201be used by listing **timer** as the trigger.
202
203This trigger will run based on a cron-style time specification.
204It will enqueue an event into its pipeline for every project
205defined in the configuration. Any job associated with the
206pipeline will run in response to that event.
207
208 **time**
209 The time specification in cron syntax. Only the 5 part syntax is
210 supported, not the symbolic names. Example: ``0 0 * * *`` runs
211 at midnight.
212
James E. Blairc494d542014-08-06 09:23:52 -0700213Zuul
214----
215
216The Zuul trigger generates events based on internal actions in Zuul.
Joshua Heskethfe485c62015-08-11 23:42:34 +1000217Multiple events may be listed.
218
219Zuul events don't require a special connection or driver. Instead they
220can be used by listing **zuul** as the trigger.
221
222 **event**
223 The event name. Currently supported:
224
225 *project-change-merged* when Zuul merges a change to a project,
226 it generates this event for every open change in the project.
227
228 *parent-change-enqueued* when Zuul enqueues a change into any
229 pipeline, it generates this event for every child of that
230 change.
231
232 **pipeline**
233 Only available for ``parent-change-enqueued`` events. This is the
234 name of the pipeline in which the parent change was enqueued.
235
236 *require-approval*
237 This may be used for any event. It requires that a certain kind
238 of approval be present for the current patchset of the change (the
239 approval could be added by the event in question). It follows the
240 same syntax as the :ref:`"approval" pipeline requirement
241 <pipeline-require-approval>`. For each specified criteria there must
242 exist a matching approval.
243
244 *reject-approval*
245 This takes a list of approvals in the same format as
246 *require-approval* but will fail to enter the pipeline if there is
Gregory Haynes4fc12542015-04-22 20:38:06 -0700247 a matching approval.