James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 1 | :title: GitHub Driver |
| 2 | |
| 3 | GitHub |
| 4 | ====== |
| 5 | |
| 6 | The GitHub driver supports sources, triggers, and reporters. It can |
| 7 | interact with the public GitHub service as well as site-local |
| 8 | installations of GitHub enterprise. |
| 9 | |
| 10 | .. TODO: make this section more user friendly |
| 11 | |
| 12 | Configure GitHub `webhook events |
| 13 | <https://developer.github.com/webhooks/creating/>`_. |
| 14 | |
| 15 | Set *Payload URL* to |
| 16 | ``http://<zuul-hostname>/connection/<connection-name>/payload``. |
| 17 | |
| 18 | Set *Content Type* to ``application/json``. |
| 19 | |
| 20 | Select *Events* you are interested in. See below for the supported events. |
| 21 | |
| 22 | Connection Configuration |
| 23 | ------------------------ |
| 24 | |
Monty Taylor | ae1f03a | 2017-07-27 14:43:32 -0500 | [diff] [blame] | 25 | There are two forms of operation. Either the Zuul installation can be |
| 26 | configured as a `Github App`_ or it can be configured as a Webhook. |
| 27 | |
| 28 | If 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`` |
| 30 | setting is required. |
| 31 | |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 32 | The supported options in zuul.conf connections are: |
| 33 | |
| 34 | **driver=github** |
| 35 | |
Monty Taylor | ae1f03a | 2017-07-27 14:43:32 -0500 | [diff] [blame] | 36 | **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. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 45 | **api_token** |
Monty Taylor | ae1f03a | 2017-07-27 14:43:32 -0500 | [diff] [blame] | 46 | API token for accessing GitHub if Zuul is configured with Webhooks. |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 47 | 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** |
Clint Byrum | cf1b742 | 2017-07-27 17:12:00 -0700 | [diff] [blame^] | 51 | Required token for validating the webhook event payloads. In the |
| 52 | GitHub App Configuration page, this is called "Webhook secret". |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 53 | See `Securing your webhooks |
| 54 | <https://developer.github.com/webhooks/securing/>`_. |
| 55 | |
| 56 | **sshkey** |
| 57 | Path to SSH key to use when cloning github repositories. |
| 58 | ``sshkey=/home/zuul/.ssh/id_rsa`` |
| 59 | |
James E. Blair | 5f11ff3 | 2017-06-23 21:46:45 +0100 | [diff] [blame] | 60 | **server** |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 61 | Optional: Hostname of the github install (such as a GitHub Enterprise) |
| 62 | If not specified, defaults to ``github.com`` |
James E. Blair | 5f11ff3 | 2017-06-23 21:46:45 +0100 | [diff] [blame] | 63 | ``server=github.myenterprise.com`` |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 64 | |
James E. Blair | 4d5dd25 | 2017-06-23 21:40:56 +0100 | [diff] [blame] | 65 | **canonical_hostname** |
| 66 | The canonical hostname associated with the git repos on the GitHub |
James E. Blair | 5f11ff3 | 2017-06-23 21:46:45 +0100 | [diff] [blame] | 67 | server. Defaults to the value of **server**. This is used to |
James E. Blair | cc3ca7d | 2017-06-29 11:09:18 -0700 | [diff] [blame] | 68 | identify projects from this connection by name and in preparing |
| 69 | repos on the filesystem for use by jobs. Note that Zuul will still |
| 70 | only communicate with the GitHub server identified by **server**; |
| 71 | this option is useful if users customarily use a different hostname |
| 72 | to clone or pull git repos so that when Zuul places them in the |
| 73 | job's working directory, they appear under this directory name. |
James E. Blair | 4d5dd25 | 2017-06-23 21:40:56 +0100 | [diff] [blame] | 74 | ``canonical_hostname=git.example.com`` |
| 75 | |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 76 | Trigger Configuration |
| 77 | --------------------- |
| 78 | GitHub webhook events can be configured as triggers. |
| 79 | |
| 80 | A connection name with the github driver can take multiple events with the |
| 81 | following options. |
| 82 | |
| 83 | **event** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 84 | The event from github. Supported events are ``pull_request``, |
| 85 | ``pull_request_review``, and ``push``. |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 86 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 87 | A ``pull_request`` event will have associated action(s) to trigger |
| 88 | from. The supported actions are: |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 89 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 90 | *opened* - pull request opened |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 91 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 92 | *changed* - pull request synchronized |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 93 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 94 | *closed* - pull request closed |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 95 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 96 | *reopened* - pull request reopened |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 97 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 98 | *comment* - comment added on pull request |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 99 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 100 | *labeled* - label added on pull request |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 101 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 102 | *unlabeled* - label removed from pull request |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 103 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 104 | *status* - status set on commit |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 105 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 106 | A ``pull_request_review`` event will |
| 107 | have associated action(s) to trigger from. The supported actions are: |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 108 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 109 | *submitted* - pull request review added |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 110 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 111 | *dismissed* - pull request review removed |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 112 | |
| 113 | **branch** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 114 | The branch associated with the event. Example: ``master``. This |
| 115 | field is treated as a regular expression, and multiple branches may |
| 116 | be listed. Used for ``pull_request`` and ``pull_request_review`` |
| 117 | events. |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 118 | |
| 119 | **comment** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 120 | This is only used for ``pull_request`` ``comment`` actions. It |
| 121 | accepts a list of regexes that are searched for in the comment |
| 122 | string. If any of these regexes matches a portion of the comment |
| 123 | string the trigger is matched. ``comment: retrigger`` will match |
| 124 | when comments containing 'retrigger' somewhere in the comment text |
| 125 | are added to a pull request. |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 126 | |
| 127 | **label** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 128 | This is only used for ``labeled`` and ``unlabeled`` ``pull_request`` |
| 129 | actions. It accepts a list of strings each of which matches the |
| 130 | label name in the event literally. ``label: recheck`` will match a |
| 131 | ``labeled`` action when pull request is labeled with a ``recheck`` |
| 132 | label. ``label: 'do not test'`` will match a ``unlabeled`` action |
| 133 | when a label with name ``do not test`` is removed from the pull |
| 134 | request. |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 135 | |
| 136 | **state** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 137 | This is only used for ``pull_request_review`` events. It accepts a |
| 138 | list of strings each of which is matched to the review state, which |
| 139 | can be one of ``approved``, ``comment``, or ``request_changes``. |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 140 | |
| 141 | **status** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 142 | This is used for ``pull-request`` and ``status`` actions. It accepts |
| 143 | a list of strings each of which matches the user setting the status, |
| 144 | the status context, and the status itself in the format of |
| 145 | ``user:context:status``. For example, |
| 146 | ``zuul_github_ci_bot:check_pipeline:success``. |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 147 | |
| 148 | **ref** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 149 | This is only used for ``push`` events. This field is treated as a |
| 150 | regular expression and multiple refs may be listed. GitHub always |
| 151 | sends full ref name, eg. ``refs/tags/bar`` and this string is |
| 152 | matched against the regexp. |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 153 | |
| 154 | Reporter Configuration |
| 155 | ---------------------- |
| 156 | Zuul reports back to GitHub via GitHub API. Available reports include a PR |
| 157 | comment containing the build results, a commit status on start, success and |
| 158 | failure, an issue label addition/removal on the PR, and a merge of the PR |
| 159 | itself. Status name, description, and context is taken from the pipeline. |
| 160 | |
| 161 | A :ref:`connection<connections>` that uses the github driver must be |
| 162 | supplied to the reporter. It has the following options: |
| 163 | |
| 164 | **status** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 165 | String value (``pending``, ``success``, ``failure``) that the |
| 166 | reporter should set as the commit status on github. ``status: |
| 167 | 'success'`` |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 168 | |
| 169 | **status-url** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 170 | String value for a link url to set in the github status. Defaults to |
| 171 | the zuul server status_url, or the empty string if that is unset. |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 172 | |
| 173 | **comment** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 174 | Boolean value (``true`` or ``false``) that determines if the |
| 175 | reporter should add a comment to the pipeline status to the github |
| 176 | pull request. Defaults to ``true``. Only used for Pull Request based |
| 177 | events. ``comment: false`` |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 178 | |
| 179 | **merge** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 180 | Boolean value (``true`` or ``false``) that determines if the |
| 181 | reporter should merge the pull reqeust. Defaults to ``false``. Only |
| 182 | used for Pull Request based events. ``merge=true`` |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 183 | |
| 184 | **label** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 185 | List of strings each representing an exact label name which should |
| 186 | be added to the pull request by reporter. Only used for Pull Request |
| 187 | based events. ``label: 'test successful'`` |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 188 | |
| 189 | **unlabel** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 190 | List of strings each representing an exact label name which should |
| 191 | be removed from the pull request by reporter. Only used for Pull |
| 192 | Request based events. ``unlabel: 'test failed'`` |
Monty Taylor | ae1f03a | 2017-07-27 14:43:32 -0500 | [diff] [blame] | 193 | |
| 194 | .. _Github App: https://developer.github.com/apps/ |