blob: 9aadf7f48a0f20d349f879494e722a60af048bbe [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
44**git_host**
45 Optional: Hostname of the github install (such as a GitHub Enterprise)
46 If not specified, defaults to ``github.com``
47 ``git_host=github.myenterprise.com``
48
James E. Blair4d5dd252017-06-23 21:40:56 +010049**canonical_hostname**
50 The canonical hostname associated with the git repos on the GitHub
51 server. Defaults to the value of **git_host**. This is used to
52 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**
68The event from github. Supported events are ``pull_request``,
69``pull_request_review``, and ``push``.
70
71A ``pull_request`` event will
72have associated action(s) to trigger from. The supported actions are:
73
74 *opened* - pull request opened
75
76 *changed* - pull request synchronized
77
78 *closed* - pull request closed
79
80 *reopened* - pull request reopened
81
82 *comment* - comment added on pull request
83
84 *labeled* - label added on pull request
85
86 *unlabeled* - label removed from pull request
87
88 *status* - status set on commit
89
90A ``pull_request_review`` event will
91have associated action(s) to trigger from. The supported actions are:
92
93 *submitted* - pull request review added
94
95 *dismissed* - pull request review removed
96
97**branch**
98The branch associated with the event. Example: ``master``. This
99field is treated as a regular expression, and multiple branches may
100be listed. Used for ``pull_request`` and ``pull_request_review`` events.
101
102**comment**
103This is only used for ``pull_request`` ``comment`` actions. It accepts a
104list of regexes that are searched for in the comment string. If any of these
105regexes matches a portion of the comment string the trigger is matched.
106``comment: retrigger`` will match when comments containing 'retrigger'
107somewhere in the comment text are added to a pull request.
108
109**label**
110This is only used for ``labeled`` and ``unlabeled`` ``pull_request`` actions.
111It accepts a list of strings each of which matches the label name in the
112event literally. ``label: recheck`` will match a ``labeled`` action when
113pull request is labeled with a ``recheck`` label. ``label: 'do not test'``
114will match a ``unlabeled`` action when a label with name ``do not test`` is
115removed from the pull request.
116
117**state**
118This is only used for ``pull_request_review`` events. It accepts a list of
119strings each of which is matched to the review state, which can be one of
120``approved``, ``comment``, or ``request_changes``.
121
122**status**
123This is used for ``pull-request`` and ``status`` actions. It accepts a
124list of strings each of which matches the user setting the status, the
125status context, and the status itself in the format of
126``user:context:status``. For example,
127``zuul_github_ci_bot:check_pipeline:success``.
128
129**ref**
130This is only used for ``push`` events. This field is treated as a regular
131expression and multiple refs may be listed. GitHub always sends full ref
132name, eg. ``refs/tags/bar`` and this string is matched against the regexp.
133
134Reporter Configuration
135----------------------
136Zuul reports back to GitHub via GitHub API. Available reports include a PR
137comment containing the build results, a commit status on start, success and
138failure, an issue label addition/removal on the PR, and a merge of the PR
139itself. Status name, description, and context is taken from the pipeline.
140
141A :ref:`connection<connections>` that uses the github driver must be
142supplied to the reporter. It has the following options:
143
144**status**
145String value (``pending``, ``success``, ``failure``) that the reporter should
146set as the commit status on github.
147``status: 'success'``
148
149**status-url**
150String value for a link url to set in the github status. Defaults to the zuul
151server status_url, or the empty string if that is unset.
152
153**comment**
154Boolean value (``true`` or ``false``) that determines if the reporter should
155add a comment to the pipeline status to the github pull request. Defaults
156to ``true``. Only used for Pull Request based events.
157``comment: false``
158
159**merge**
160Boolean value (``true`` or ``false``) that determines if the reporter should
161merge the pull reqeust. Defaults to ``false``. Only used for Pull Request based
162events.
163``merge=true``
164
165**label**
166List of strings each representing an exact label name which should be added
167to the pull request by reporter. Only used for Pull Request based events.
168``label: 'test successful'``
169
170**unlabel**
171List of strings each representing an exact label name which should be removed
172from the pull request by reporter. Only used for Pull Request based events.
173``unlabel: 'test failed'``