blob: 5075f8075d3adf374b49a00af71c4673c1ff795d [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".
39
40**app_key**
41 The Secret Key Zuul will use to create tokens for the API interactions.
42 In Github this is known as "Private key" and must be collected when
43 generated.
44
James E. Blaireff5a9d2017-06-20 00:00:37 -070045**api_token**
Monty Taylorae1f03a2017-07-27 14:43:32 -050046 API token for accessing GitHub if Zuul is configured with Webhooks.
James E. Blaireff5a9d2017-06-20 00:00:37 -070047 See `Creating an access token for command-line use
48 <https://help.github.com/articles/creating-an-access-token-for-command-line-use/>`_.
49
50**webhook_token**
51 Optional: Token for validating the webhook event payloads.
Monty Taylorae1f03a2017-07-27 14:43:32 -050052 If not specified, payloads are not validated. In the GitHub App Configuration
53 page, this is called "Webhook secret".
James E. Blaireff5a9d2017-06-20 00:00:37 -070054 See `Securing your webhooks
55 <https://developer.github.com/webhooks/securing/>`_.
56
57**sshkey**
58 Path to SSH key to use when cloning github repositories.
59 ``sshkey=/home/zuul/.ssh/id_rsa``
60
James E. Blair5f11ff32017-06-23 21:46:45 +010061**server**
James E. Blaireff5a9d2017-06-20 00:00:37 -070062 Optional: Hostname of the github install (such as a GitHub Enterprise)
63 If not specified, defaults to ``github.com``
James E. Blair5f11ff32017-06-23 21:46:45 +010064 ``server=github.myenterprise.com``
James E. Blaireff5a9d2017-06-20 00:00:37 -070065
James E. Blair4d5dd252017-06-23 21:40:56 +010066**canonical_hostname**
67 The canonical hostname associated with the git repos on the GitHub
James E. Blair5f11ff32017-06-23 21:46:45 +010068 server. Defaults to the value of **server**. This is used to
James E. Blaircc3ca7d2017-06-29 11:09:18 -070069 identify projects from this connection by name and in preparing
70 repos on the filesystem for use by jobs. Note that Zuul will still
71 only communicate with the GitHub server identified by **server**;
72 this option is useful if users customarily use a different hostname
73 to clone or pull git repos so that when Zuul places them in the
74 job's working directory, they appear under this directory name.
James E. Blair4d5dd252017-06-23 21:40:56 +010075 ``canonical_hostname=git.example.com``
76
James E. Blaireff5a9d2017-06-20 00:00:37 -070077Trigger Configuration
78---------------------
79GitHub webhook events can be configured as triggers.
80
81A connection name with the github driver can take multiple events with the
82following options.
83
84**event**
James E. Blair88e53882017-06-23 21:45:07 +010085 The event from github. Supported events are ``pull_request``,
86 ``pull_request_review``, and ``push``.
James E. Blaireff5a9d2017-06-20 00:00:37 -070087
James E. Blair88e53882017-06-23 21:45:07 +010088 A ``pull_request`` event will have associated action(s) to trigger
89 from. The supported actions are:
James E. Blaireff5a9d2017-06-20 00:00:37 -070090
James E. Blair88e53882017-06-23 21:45:07 +010091 *opened* - pull request opened
James E. Blaireff5a9d2017-06-20 00:00:37 -070092
James E. Blair88e53882017-06-23 21:45:07 +010093 *changed* - pull request synchronized
James E. Blaireff5a9d2017-06-20 00:00:37 -070094
James E. Blair88e53882017-06-23 21:45:07 +010095 *closed* - pull request closed
James E. Blaireff5a9d2017-06-20 00:00:37 -070096
James E. Blair88e53882017-06-23 21:45:07 +010097 *reopened* - pull request reopened
James E. Blaireff5a9d2017-06-20 00:00:37 -070098
James E. Blair88e53882017-06-23 21:45:07 +010099 *comment* - comment added on pull request
James E. Blaireff5a9d2017-06-20 00:00:37 -0700100
James E. Blair88e53882017-06-23 21:45:07 +0100101 *labeled* - label added on pull request
James E. Blaireff5a9d2017-06-20 00:00:37 -0700102
James E. Blair88e53882017-06-23 21:45:07 +0100103 *unlabeled* - label removed from pull request
James E. Blaireff5a9d2017-06-20 00:00:37 -0700104
James E. Blair88e53882017-06-23 21:45:07 +0100105 *status* - status set on commit
James E. Blaireff5a9d2017-06-20 00:00:37 -0700106
James E. Blair88e53882017-06-23 21:45:07 +0100107 A ``pull_request_review`` event will
108 have associated action(s) to trigger from. The supported actions are:
James E. Blaireff5a9d2017-06-20 00:00:37 -0700109
James E. Blair88e53882017-06-23 21:45:07 +0100110 *submitted* - pull request review added
James E. Blaireff5a9d2017-06-20 00:00:37 -0700111
James E. Blair88e53882017-06-23 21:45:07 +0100112 *dismissed* - pull request review removed
James E. Blaireff5a9d2017-06-20 00:00:37 -0700113
114**branch**
James E. Blair88e53882017-06-23 21:45:07 +0100115 The branch associated with the event. Example: ``master``. This
116 field is treated as a regular expression, and multiple branches may
117 be listed. Used for ``pull_request`` and ``pull_request_review``
118 events.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700119
120**comment**
James E. Blair88e53882017-06-23 21:45:07 +0100121 This is only used for ``pull_request`` ``comment`` actions. It
122 accepts a list of regexes that are searched for in the comment
123 string. If any of these regexes matches a portion of the comment
124 string the trigger is matched. ``comment: retrigger`` will match
125 when comments containing 'retrigger' somewhere in the comment text
126 are added to a pull request.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700127
128**label**
James E. Blair88e53882017-06-23 21:45:07 +0100129 This is only used for ``labeled`` and ``unlabeled`` ``pull_request``
130 actions. It accepts a list of strings each of which matches the
131 label name in the event literally. ``label: recheck`` will match a
132 ``labeled`` action when pull request is labeled with a ``recheck``
133 label. ``label: 'do not test'`` will match a ``unlabeled`` action
134 when a label with name ``do not test`` is removed from the pull
135 request.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700136
137**state**
James E. Blair88e53882017-06-23 21:45:07 +0100138 This is only used for ``pull_request_review`` events. It accepts a
139 list of strings each of which is matched to the review state, which
140 can be one of ``approved``, ``comment``, or ``request_changes``.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700141
142**status**
James E. Blair88e53882017-06-23 21:45:07 +0100143 This is used for ``pull-request`` and ``status`` actions. It accepts
144 a list of strings each of which matches the user setting the status,
145 the status context, and the status itself in the format of
146 ``user:context:status``. For example,
147 ``zuul_github_ci_bot:check_pipeline:success``.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700148
149**ref**
James E. Blair88e53882017-06-23 21:45:07 +0100150 This is only used for ``push`` events. This field is treated as a
151 regular expression and multiple refs may be listed. GitHub always
152 sends full ref name, eg. ``refs/tags/bar`` and this string is
153 matched against the regexp.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700154
155Reporter Configuration
156----------------------
157Zuul reports back to GitHub via GitHub API. Available reports include a PR
158comment containing the build results, a commit status on start, success and
159failure, an issue label addition/removal on the PR, and a merge of the PR
160itself. Status name, description, and context is taken from the pipeline.
161
162A :ref:`connection<connections>` that uses the github driver must be
163supplied to the reporter. It has the following options:
164
165**status**
James E. Blair88e53882017-06-23 21:45:07 +0100166 String value (``pending``, ``success``, ``failure``) that the
167 reporter should set as the commit status on github. ``status:
168 'success'``
James E. Blaireff5a9d2017-06-20 00:00:37 -0700169
170**status-url**
James E. Blair88e53882017-06-23 21:45:07 +0100171 String value for a link url to set in the github status. Defaults to
172 the zuul server status_url, or the empty string if that is unset.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700173
174**comment**
James E. Blair88e53882017-06-23 21:45:07 +0100175 Boolean value (``true`` or ``false``) that determines if the
176 reporter should add a comment to the pipeline status to the github
177 pull request. Defaults to ``true``. Only used for Pull Request based
178 events. ``comment: false``
James E. Blaireff5a9d2017-06-20 00:00:37 -0700179
180**merge**
James E. Blair88e53882017-06-23 21:45:07 +0100181 Boolean value (``true`` or ``false``) that determines if the
182 reporter should merge the pull reqeust. Defaults to ``false``. Only
183 used for Pull Request based events. ``merge=true``
James E. Blaireff5a9d2017-06-20 00:00:37 -0700184
185**label**
James E. Blair88e53882017-06-23 21:45:07 +0100186 List of strings each representing an exact label name which should
187 be added to the pull request by reporter. Only used for Pull Request
188 based events. ``label: 'test successful'``
James E. Blaireff5a9d2017-06-20 00:00:37 -0700189
190**unlabel**
James E. Blair88e53882017-06-23 21:45:07 +0100191 List of strings each representing an exact label name which should
192 be removed from the pull request by reporter. Only used for Pull
193 Request based events. ``unlabel: 'test failed'``
Monty Taylorae1f03a2017-07-27 14:43:32 -0500194
195.. _Github App: https://developer.github.com/apps/