blob: cbbc5cc78ab450cbee37e52dbec2e53fd7a0c4f9 [file] [log] [blame]
James E. Blaireff5a9d2017-06-20 00:00:37 -07001:title: GitHub Driver
2
3GitHub
4======
5
6The GitHub driver supports sources, triggers, and reporters. It can
7interact with the public GitHub service as well as site-local
8installations of GitHub enterprise.
9
10.. TODO: make this section more user friendly
11
12Configure GitHub `webhook events
13<https://developer.github.com/webhooks/creating/>`_.
14
15Set *Payload URL* to
16``http://<zuul-hostname>/connection/<connection-name>/payload``.
17
18Set *Content Type* to ``application/json``.
19
20Select *Events* you are interested in. See below for the supported events.
21
22Connection Configuration
23------------------------
24
Monty Taylorae1f03a2017-07-27 14:43:32 -050025There are two forms of operation. Either the Zuul installation can be
26configured as a `Github App`_ or it can be configured as a Webhook.
27
28If the `Github App`_ approach is taken, the config settings ``app_id`` and
29``app_key`` are required. If the Webhook approach is taken, the ``api_token``
30setting is required.
31
James E. Blaireff5a9d2017-06-20 00:00:37 -070032The supported options in zuul.conf connections are:
33
34**driver=github**
35
Monty Taylorae1f03a2017-07-27 14:43:32 -050036**app_id**
37 App ID if you are using a GitHub App. Can be found under the "Public Link"
38 on the right hand side labeled "ID".
Monty Taylor4b203992017-07-28 04:09:19 -050039 ``app_id=1234``
Monty Taylorae1f03a2017-07-27 14:43:32 -050040
41**app_key**
Monty Taylor4b203992017-07-28 04:09:19 -050042 Path to a file containing the Secret Key Zuul will use to create tokens for
43 the API interactions. In Github this is known as "Private key" and must be
44 collected when generated.
45 ``app_key=/etc/zuul/github.key``
Monty Taylorae1f03a2017-07-27 14:43:32 -050046
James E. Blaireff5a9d2017-06-20 00:00:37 -070047**api_token**
Monty Taylorae1f03a2017-07-27 14:43:32 -050048 API token for accessing GitHub if Zuul is configured with Webhooks.
James E. Blaireff5a9d2017-06-20 00:00:37 -070049 See `Creating an access token for command-line use
50 <https://help.github.com/articles/creating-an-access-token-for-command-line-use/>`_.
51
52**webhook_token**
Clint Byrumcf1b7422017-07-27 17:12:00 -070053 Required token for validating the webhook event payloads. In the
54 GitHub App Configuration page, this is called "Webhook secret".
James E. Blaireff5a9d2017-06-20 00:00:37 -070055 See `Securing your webhooks
56 <https://developer.github.com/webhooks/securing/>`_.
57
58**sshkey**
59 Path to SSH key to use when cloning github repositories.
60 ``sshkey=/home/zuul/.ssh/id_rsa``
61
James E. Blair5f11ff32017-06-23 21:46:45 +010062**server**
James E. Blaireff5a9d2017-06-20 00:00:37 -070063 Optional: Hostname of the github install (such as a GitHub Enterprise)
64 If not specified, defaults to ``github.com``
James E. Blair5f11ff32017-06-23 21:46:45 +010065 ``server=github.myenterprise.com``
James E. Blaireff5a9d2017-06-20 00:00:37 -070066
James E. Blair4d5dd252017-06-23 21:40:56 +010067**canonical_hostname**
68 The canonical hostname associated with the git repos on the GitHub
James E. Blair5f11ff32017-06-23 21:46:45 +010069 server. Defaults to the value of **server**. This is used to
James E. Blaircc3ca7d2017-06-29 11:09:18 -070070 identify projects from this connection by name and in preparing
71 repos on the filesystem for use by jobs. Note that Zuul will still
72 only communicate with the GitHub server identified by **server**;
73 this option is useful if users customarily use a different hostname
74 to clone or pull git repos so that when Zuul places them in the
75 job's working directory, they appear under this directory name.
James E. Blair4d5dd252017-06-23 21:40:56 +010076 ``canonical_hostname=git.example.com``
77
Tobias Henkel65e0e8c2017-08-01 13:44:33 +020078**verify_ssl**
79 Optional: Enable or disable ssl verification for GitHub Enterprise. This is
80 useful for a connection to a test installation. If not specified, defaults
81 to ``true``.
82 ``verify_ssl=true``
83
James E. Blaireff5a9d2017-06-20 00:00:37 -070084Trigger Configuration
85---------------------
86GitHub webhook events can be configured as triggers.
87
88A connection name with the github driver can take multiple events with the
89following options.
90
91**event**
James E. Blair88e53882017-06-23 21:45:07 +010092 The event from github. Supported events are ``pull_request``,
93 ``pull_request_review``, and ``push``.
James E. Blaireff5a9d2017-06-20 00:00:37 -070094
James E. Blair88e53882017-06-23 21:45:07 +010095 A ``pull_request`` event will have associated action(s) to trigger
96 from. The supported actions are:
James E. Blaireff5a9d2017-06-20 00:00:37 -070097
James E. Blair88e53882017-06-23 21:45:07 +010098 *opened* - pull request opened
James E. Blaireff5a9d2017-06-20 00:00:37 -070099
James E. Blair88e53882017-06-23 21:45:07 +0100100 *changed* - pull request synchronized
James E. Blaireff5a9d2017-06-20 00:00:37 -0700101
James E. Blair88e53882017-06-23 21:45:07 +0100102 *closed* - pull request closed
James E. Blaireff5a9d2017-06-20 00:00:37 -0700103
James E. Blair88e53882017-06-23 21:45:07 +0100104 *reopened* - pull request reopened
James E. Blaireff5a9d2017-06-20 00:00:37 -0700105
James E. Blair88e53882017-06-23 21:45:07 +0100106 *comment* - comment added on pull request
James E. Blaireff5a9d2017-06-20 00:00:37 -0700107
James E. Blair88e53882017-06-23 21:45:07 +0100108 *labeled* - label added on pull request
James E. Blaireff5a9d2017-06-20 00:00:37 -0700109
James E. Blair88e53882017-06-23 21:45:07 +0100110 *unlabeled* - label removed from pull request
James E. Blaireff5a9d2017-06-20 00:00:37 -0700111
James E. Blair88e53882017-06-23 21:45:07 +0100112 *status* - status set on commit
James E. Blaireff5a9d2017-06-20 00:00:37 -0700113
James E. Blair88e53882017-06-23 21:45:07 +0100114 A ``pull_request_review`` event will
115 have associated action(s) to trigger from. The supported actions are:
James E. Blaireff5a9d2017-06-20 00:00:37 -0700116
James E. Blair88e53882017-06-23 21:45:07 +0100117 *submitted* - pull request review added
James E. Blaireff5a9d2017-06-20 00:00:37 -0700118
James E. Blair88e53882017-06-23 21:45:07 +0100119 *dismissed* - pull request review removed
James E. Blaireff5a9d2017-06-20 00:00:37 -0700120
121**branch**
James E. Blair88e53882017-06-23 21:45:07 +0100122 The branch associated with the event. Example: ``master``. This
123 field is treated as a regular expression, and multiple branches may
124 be listed. Used for ``pull_request`` and ``pull_request_review``
125 events.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700126
127**comment**
James E. Blair88e53882017-06-23 21:45:07 +0100128 This is only used for ``pull_request`` ``comment`` actions. It
129 accepts a list of regexes that are searched for in the comment
130 string. If any of these regexes matches a portion of the comment
131 string the trigger is matched. ``comment: retrigger`` will match
132 when comments containing 'retrigger' somewhere in the comment text
133 are added to a pull request.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700134
135**label**
James E. Blair88e53882017-06-23 21:45:07 +0100136 This is only used for ``labeled`` and ``unlabeled`` ``pull_request``
137 actions. It accepts a list of strings each of which matches the
138 label name in the event literally. ``label: recheck`` will match a
139 ``labeled`` action when pull request is labeled with a ``recheck``
140 label. ``label: 'do not test'`` will match a ``unlabeled`` action
141 when a label with name ``do not test`` is removed from the pull
142 request.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700143
144**state**
James E. Blair88e53882017-06-23 21:45:07 +0100145 This is only used for ``pull_request_review`` events. It accepts a
146 list of strings each of which is matched to the review state, which
147 can be one of ``approved``, ``comment``, or ``request_changes``.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700148
149**status**
James E. Blair88e53882017-06-23 21:45:07 +0100150 This is used for ``pull-request`` and ``status`` actions. It accepts
151 a list of strings each of which matches the user setting the status,
152 the status context, and the status itself in the format of
153 ``user:context:status``. For example,
154 ``zuul_github_ci_bot:check_pipeline:success``.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700155
156**ref**
James E. Blair88e53882017-06-23 21:45:07 +0100157 This is only used for ``push`` events. This field is treated as a
158 regular expression and multiple refs may be listed. GitHub always
159 sends full ref name, eg. ``refs/tags/bar`` and this string is
160 matched against the regexp.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700161
162Reporter Configuration
163----------------------
164Zuul reports back to GitHub via GitHub API. Available reports include a PR
165comment containing the build results, a commit status on start, success and
166failure, an issue label addition/removal on the PR, and a merge of the PR
167itself. Status name, description, and context is taken from the pipeline.
168
169A :ref:`connection<connections>` that uses the github driver must be
170supplied to the reporter. It has the following options:
171
172**status**
James E. Blair88e53882017-06-23 21:45:07 +0100173 String value (``pending``, ``success``, ``failure``) that the
174 reporter should set as the commit status on github. ``status:
175 'success'``
James E. Blaireff5a9d2017-06-20 00:00:37 -0700176
177**status-url**
James E. Blair88e53882017-06-23 21:45:07 +0100178 String value for a link url to set in the github status. Defaults to
179 the zuul server status_url, or the empty string if that is unset.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700180
181**comment**
James E. Blair88e53882017-06-23 21:45:07 +0100182 Boolean value (``true`` or ``false``) that determines if the
183 reporter should add a comment to the pipeline status to the github
184 pull request. Defaults to ``true``. Only used for Pull Request based
185 events. ``comment: false``
James E. Blaireff5a9d2017-06-20 00:00:37 -0700186
187**merge**
James E. Blair88e53882017-06-23 21:45:07 +0100188 Boolean value (``true`` or ``false``) that determines if the
189 reporter should merge the pull reqeust. Defaults to ``false``. Only
190 used for Pull Request based events. ``merge=true``
James E. Blaireff5a9d2017-06-20 00:00:37 -0700191
192**label**
James E. Blair88e53882017-06-23 21:45:07 +0100193 List of strings each representing an exact label name which should
194 be added to the pull request by reporter. Only used for Pull Request
195 based events. ``label: 'test successful'``
James E. Blaireff5a9d2017-06-20 00:00:37 -0700196
197**unlabel**
James E. Blair88e53882017-06-23 21:45:07 +0100198 List of strings each representing an exact label name which should
199 be removed from the pull request by reporter. Only used for Pull
200 Request based events. ``unlabel: 'test failed'``
Monty Taylorae1f03a2017-07-27 14:43:32 -0500201
202.. _Github App: https://developer.github.com/apps/
James E. Blaird134c6d2017-07-26 16:09:34 -0700203
204Requirements Configuration
205--------------------------
206
James E. Blair32c52482017-07-29 07:49:03 -0700207As described in :attr:`pipeline.require` and :attr:`pipeline.reject`,
208pipelines may specify that items meet certain conditions in order to
209be enqueued into the pipeline. These conditions vary according to the
210source of the project in question. To supply requirements for changes
211from a GitHub source named *my-github*, create a congfiguration such
212as the following::
James E. Blaird134c6d2017-07-26 16:09:34 -0700213
214 pipeline:
215 require:
216 my-github:
217 review:
218 - type: approval
219
220This indicates that changes originating from the GitHub connection
221named *my-github* must have an approved code review in order to be
222enqueued into the pipeline.
223
James E. Blair94375912017-07-28 17:20:27 -0700224.. attr:: pipeline.require.<github source>
James E. Blaird134c6d2017-07-26 16:09:34 -0700225
226 The dictionary passed to the GitHub pipeline `require` attribute
227 supports the following attributes:
228
James E. Blair94375912017-07-28 17:20:27 -0700229 .. attr:: review
James E. Blaird134c6d2017-07-26 16:09:34 -0700230
231 This requires that a certain kind of code review be present for
232 the pull request (it could be added by the event in question).
233 It takes several sub-parameters, all of which are optional and
234 are combined together so that there must be a code review
235 matching all specified requirements.
236
James E. Blair94375912017-07-28 17:20:27 -0700237 .. attr:: username
James E. Blaird134c6d2017-07-26 16:09:34 -0700238
239 If present, a code review from this username is required. It
240 is treated as a regular expression.
241
James E. Blair94375912017-07-28 17:20:27 -0700242 .. attr:: email
James E. Blaird134c6d2017-07-26 16:09:34 -0700243
244 If present, a code review with this email address is
245 required. It is treated as a regular expression.
246
James E. Blair94375912017-07-28 17:20:27 -0700247 .. attr:: older-than
James E. Blaird134c6d2017-07-26 16:09:34 -0700248
249 If present, the code review must be older than this amount of
250 time to match. Provide a time interval as a number with a
251 suffix of "w" (weeks), "d" (days), "h" (hours), "m"
252 (minutes), "s" (seconds). Example ``48h`` or ``2d``.
253
James E. Blair94375912017-07-28 17:20:27 -0700254 .. attr:: newer-than
James E. Blaird134c6d2017-07-26 16:09:34 -0700255
256 If present, the code review must be newer than this amount of
257 time to match. Same format as "older-than".
258
James E. Blair94375912017-07-28 17:20:27 -0700259 .. attr:: type
James E. Blaird134c6d2017-07-26 16:09:34 -0700260
261 If present, the code review must match this type (or types).
262
263 .. TODO: what types are valid?
264
James E. Blair94375912017-07-28 17:20:27 -0700265 .. attr:: permission
James E. Blaird134c6d2017-07-26 16:09:34 -0700266
267 If present, the author of the code review must have this
268 permission (or permissions). The available values are
269 ``read``, ``write``, and ``admin``.
270
James E. Blair94375912017-07-28 17:20:27 -0700271 .. attr:: open
James E. Blaird134c6d2017-07-26 16:09:34 -0700272
273 A boolean value (``true`` or ``false``) that indicates whether
274 the change must be open or closed in order to be enqueued.
275
James E. Blair94375912017-07-28 17:20:27 -0700276 .. attr:: current-patchset
James E. Blaird134c6d2017-07-26 16:09:34 -0700277
278 A boolean value (``true`` or ``false``) that indicates whether
279 the item must be associated with the latest commit in the pull
280 request in order to be enqueued.
281
282 .. TODO: this could probably be expanded upon -- under what
283 circumstances might this happen with github
284
James E. Blair94375912017-07-28 17:20:27 -0700285 .. attr:: status
James E. Blaird134c6d2017-07-26 16:09:34 -0700286
287 A string value that corresponds with the status of the pull
288 request. The syntax is ``user:status:value``.
289
James E. Blair94375912017-07-28 17:20:27 -0700290 .. attr:: label
James E. Blaird134c6d2017-07-26 16:09:34 -0700291
292 A string value indicating that the pull request must have the
293 indicated label (or labels).
294
295
James E. Blair94375912017-07-28 17:20:27 -0700296.. attr:: pipeline.reject.<github source>
James E. Blaird134c6d2017-07-26 16:09:34 -0700297
298 The `reject` attribute is the mirror of the `require` attribute. It
299 also accepts a dictionary under the connection name. This
300 dictionary supports the following attributes:
301
James E. Blair94375912017-07-28 17:20:27 -0700302 .. attr:: review
James E. Blaird134c6d2017-07-26 16:09:34 -0700303
304 This takes a list of code reviews. If a code review matches the
305 provided criteria the pull request can not be entered into the
James E. Blair91fe4832017-07-28 17:28:26 -0700306 pipeline. It follows the same syntax as
307 :attr:`pipeline.require.<github source>.review`