blob: 9f116ee52aab740e02d7690d480efacd263b1fb3 [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
25The supported options in zuul.conf connections are:
26
27**driver=github**
28
29**api_token**
30 API token for accessing GitHub.
31 See `Creating an access token for command-line use
32 <https://help.github.com/articles/creating-an-access-token-for-command-line-use/>`_.
33
34**webhook_token**
35 Optional: Token for validating the webhook event payloads.
36 If not specified, payloads are not validated.
37 See `Securing your webhooks
38 <https://developer.github.com/webhooks/securing/>`_.
39
40**sshkey**
41 Path to SSH key to use when cloning github repositories.
42 ``sshkey=/home/zuul/.ssh/id_rsa``
43
James E. Blair5f11ff32017-06-23 21:46:45 +010044**server**
James E. Blaireff5a9d2017-06-20 00:00:37 -070045 Optional: Hostname of the github install (such as a GitHub Enterprise)
46 If not specified, defaults to ``github.com``
James E. Blair5f11ff32017-06-23 21:46:45 +010047 ``server=github.myenterprise.com``
James E. Blaireff5a9d2017-06-20 00:00:37 -070048
James E. Blair4d5dd252017-06-23 21:40:56 +010049**canonical_hostname**
50 The canonical hostname associated with the git repos on the GitHub
James E. Blair5f11ff32017-06-23 21:46:45 +010051 server. Defaults to the value of **server**. This is used to
James E. Blair4d5dd252017-06-23 21:40:56 +010052 identify repos from this connection by name and in preparing repos
53 on the filesystem for use by jobs. This only needs to be set in the
54 case where the canonical public location of the git repos is not the
55 same as the GitHub server and it would be incorrect to refer to
56 those repos in configuration and build scripts using the GitHub
57 server hostname.
58 ``canonical_hostname=git.example.com``
59
James E. Blaireff5a9d2017-06-20 00:00:37 -070060Trigger Configuration
61---------------------
62GitHub webhook events can be configured as triggers.
63
64A connection name with the github driver can take multiple events with the
65following options.
66
67**event**
James E. Blair88e53882017-06-23 21:45:07 +010068 The event from github. Supported events are ``pull_request``,
69 ``pull_request_review``, and ``push``.
James E. Blaireff5a9d2017-06-20 00:00:37 -070070
James E. Blair88e53882017-06-23 21:45:07 +010071 A ``pull_request`` event will have associated action(s) to trigger
72 from. The supported actions are:
James E. Blaireff5a9d2017-06-20 00:00:37 -070073
James E. Blair88e53882017-06-23 21:45:07 +010074 *opened* - pull request opened
James E. Blaireff5a9d2017-06-20 00:00:37 -070075
James E. Blair88e53882017-06-23 21:45:07 +010076 *changed* - pull request synchronized
James E. Blaireff5a9d2017-06-20 00:00:37 -070077
James E. Blair88e53882017-06-23 21:45:07 +010078 *closed* - pull request closed
James E. Blaireff5a9d2017-06-20 00:00:37 -070079
James E. Blair88e53882017-06-23 21:45:07 +010080 *reopened* - pull request reopened
James E. Blaireff5a9d2017-06-20 00:00:37 -070081
James E. Blair88e53882017-06-23 21:45:07 +010082 *comment* - comment added on pull request
James E. Blaireff5a9d2017-06-20 00:00:37 -070083
James E. Blair88e53882017-06-23 21:45:07 +010084 *labeled* - label added on pull request
James E. Blaireff5a9d2017-06-20 00:00:37 -070085
James E. Blair88e53882017-06-23 21:45:07 +010086 *unlabeled* - label removed from pull request
James E. Blaireff5a9d2017-06-20 00:00:37 -070087
James E. Blair88e53882017-06-23 21:45:07 +010088 *status* - status set on commit
James E. Blaireff5a9d2017-06-20 00:00:37 -070089
James E. Blair88e53882017-06-23 21:45:07 +010090 A ``pull_request_review`` event will
91 have associated action(s) to trigger from. The supported actions are:
James E. Blaireff5a9d2017-06-20 00:00:37 -070092
James E. Blair88e53882017-06-23 21:45:07 +010093 *submitted* - pull request review added
James E. Blaireff5a9d2017-06-20 00:00:37 -070094
James E. Blair88e53882017-06-23 21:45:07 +010095 *dismissed* - pull request review removed
James E. Blaireff5a9d2017-06-20 00:00:37 -070096
97**branch**
James E. Blair88e53882017-06-23 21:45:07 +010098 The branch associated with the event. Example: ``master``. This
99 field is treated as a regular expression, and multiple branches may
100 be listed. Used for ``pull_request`` and ``pull_request_review``
101 events.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700102
103**comment**
James E. Blair88e53882017-06-23 21:45:07 +0100104 This is only used for ``pull_request`` ``comment`` actions. It
105 accepts a list of regexes that are searched for in the comment
106 string. If any of these regexes matches a portion of the comment
107 string the trigger is matched. ``comment: retrigger`` will match
108 when comments containing 'retrigger' somewhere in the comment text
109 are added to a pull request.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700110
111**label**
James E. Blair88e53882017-06-23 21:45:07 +0100112 This is only used for ``labeled`` and ``unlabeled`` ``pull_request``
113 actions. It accepts a list of strings each of which matches the
114 label name in the event literally. ``label: recheck`` will match a
115 ``labeled`` action when pull request is labeled with a ``recheck``
116 label. ``label: 'do not test'`` will match a ``unlabeled`` action
117 when a label with name ``do not test`` is removed from the pull
118 request.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700119
120**state**
James E. Blair88e53882017-06-23 21:45:07 +0100121 This is only used for ``pull_request_review`` events. It accepts a
122 list of strings each of which is matched to the review state, which
123 can be one of ``approved``, ``comment``, or ``request_changes``.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700124
125**status**
James E. Blair88e53882017-06-23 21:45:07 +0100126 This is used for ``pull-request`` and ``status`` actions. It accepts
127 a list of strings each of which matches the user setting the status,
128 the status context, and the status itself in the format of
129 ``user:context:status``. For example,
130 ``zuul_github_ci_bot:check_pipeline:success``.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700131
132**ref**
James E. Blair88e53882017-06-23 21:45:07 +0100133 This is only used for ``push`` events. This field is treated as a
134 regular expression and multiple refs may be listed. GitHub always
135 sends full ref name, eg. ``refs/tags/bar`` and this string is
136 matched against the regexp.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700137
138Reporter Configuration
139----------------------
140Zuul reports back to GitHub via GitHub API. Available reports include a PR
141comment containing the build results, a commit status on start, success and
142failure, an issue label addition/removal on the PR, and a merge of the PR
143itself. Status name, description, and context is taken from the pipeline.
144
145A :ref:`connection<connections>` that uses the github driver must be
146supplied to the reporter. It has the following options:
147
148**status**
James E. Blair88e53882017-06-23 21:45:07 +0100149 String value (``pending``, ``success``, ``failure``) that the
150 reporter should set as the commit status on github. ``status:
151 'success'``
James E. Blaireff5a9d2017-06-20 00:00:37 -0700152
153**status-url**
James E. Blair88e53882017-06-23 21:45:07 +0100154 String value for a link url to set in the github status. Defaults to
155 the zuul server status_url, or the empty string if that is unset.
James E. Blaireff5a9d2017-06-20 00:00:37 -0700156
157**comment**
James E. Blair88e53882017-06-23 21:45:07 +0100158 Boolean value (``true`` or ``false``) that determines if the
159 reporter should add a comment to the pipeline status to the github
160 pull request. Defaults to ``true``. Only used for Pull Request based
161 events. ``comment: false``
James E. Blaireff5a9d2017-06-20 00:00:37 -0700162
163**merge**
James E. Blair88e53882017-06-23 21:45:07 +0100164 Boolean value (``true`` or ``false``) that determines if the
165 reporter should merge the pull reqeust. Defaults to ``false``. Only
166 used for Pull Request based events. ``merge=true``
James E. Blaireff5a9d2017-06-20 00:00:37 -0700167
168**label**
James E. Blair88e53882017-06-23 21:45:07 +0100169 List of strings each representing an exact label name which should
170 be added to the pull request by reporter. Only used for Pull Request
171 based events. ``label: 'test successful'``
James E. Blaireff5a9d2017-06-20 00:00:37 -0700172
173**unlabel**
James E. Blair88e53882017-06-23 21:45:07 +0100174 List of strings each representing an exact label name which should
175 be removed from the pull request by reporter. Only used for Pull
176 Request based events. ``unlabel: 'test failed'``