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 | |
| 25 | The 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. Blair | 4d5dd25 | 2017-06-23 21:40:56 +0100 | [diff] [blame] | 49 | **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. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 60 | Trigger Configuration |
| 61 | --------------------- |
| 62 | GitHub webhook events can be configured as triggers. |
| 63 | |
| 64 | A connection name with the github driver can take multiple events with the |
| 65 | following options. |
| 66 | |
| 67 | **event** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 68 | The event from github. Supported events are ``pull_request``, |
| 69 | ``pull_request_review``, and ``push``. |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 70 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 71 | A ``pull_request`` event will have associated action(s) to trigger |
| 72 | from. The supported actions are: |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 73 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 74 | *opened* - pull request opened |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 75 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 76 | *changed* - pull request synchronized |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 77 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 78 | *closed* - pull request closed |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 79 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 80 | *reopened* - pull request reopened |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 81 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 82 | *comment* - comment added on pull request |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 83 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 84 | *labeled* - label added on pull request |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 85 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 86 | *unlabeled* - label removed from pull request |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 87 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 88 | *status* - status set on commit |
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 | A ``pull_request_review`` event will |
| 91 | have associated action(s) to trigger from. The supported actions are: |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 92 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 93 | *submitted* - pull request review added |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 94 | |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 95 | *dismissed* - pull request review removed |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 96 | |
| 97 | **branch** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 98 | 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. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 102 | |
| 103 | **comment** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 104 | 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. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 110 | |
| 111 | **label** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 112 | 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. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 119 | |
| 120 | **state** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 121 | 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. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 124 | |
| 125 | **status** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 126 | 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. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 131 | |
| 132 | **ref** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 133 | 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. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 137 | |
| 138 | Reporter Configuration |
| 139 | ---------------------- |
| 140 | Zuul reports back to GitHub via GitHub API. Available reports include a PR |
| 141 | comment containing the build results, a commit status on start, success and |
| 142 | failure, an issue label addition/removal on the PR, and a merge of the PR |
| 143 | itself. Status name, description, and context is taken from the pipeline. |
| 144 | |
| 145 | A :ref:`connection<connections>` that uses the github driver must be |
| 146 | supplied to the reporter. It has the following options: |
| 147 | |
| 148 | **status** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 149 | String value (``pending``, ``success``, ``failure``) that the |
| 150 | reporter should set as the commit status on github. ``status: |
| 151 | 'success'`` |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 152 | |
| 153 | **status-url** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 154 | 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. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 156 | |
| 157 | **comment** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 158 | 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. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 162 | |
| 163 | **merge** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 164 | 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. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 167 | |
| 168 | **label** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 169 | 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. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 172 | |
| 173 | **unlabel** |
James E. Blair | 88e5388 | 2017-06-23 21:45:07 +0100 | [diff] [blame] | 174 | 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'`` |