James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 1 | :title: Zuul |
| 2 | |
| 3 | Zuul |
| 4 | ==== |
| 5 | |
| 6 | Configuration |
| 7 | ------------- |
| 8 | |
| 9 | Zuul has three configuration files: |
| 10 | |
| 11 | **zuul.conf** |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 12 | Connection information for Gerrit and Gearman, locations of the |
| 13 | other config files |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 14 | **layout.yaml** |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 15 | Project and pipeline configuration -- what Zuul does |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 16 | **logging.conf** |
| 17 | Python logging config |
| 18 | |
| 19 | Examples of each of the three files can be found in the etc/ directory |
| 20 | of the source distribution. |
| 21 | |
James E. Blair | 6aea36d | 2012-12-17 13:03:24 -0800 | [diff] [blame] | 22 | .. _zuulconf: |
| 23 | |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 24 | zuul.conf |
| 25 | ~~~~~~~~~ |
| 26 | |
| 27 | Zuul will look for ``/etc/zuul/zuul.conf`` or ``~/zuul.conf`` to |
| 28 | bootstrap its configuration. Alternately, you may specify ``-c |
| 29 | /path/to/zuul.conf`` on the command line. |
| 30 | |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 31 | Gerrit and Gearman connection information are each described in a |
| 32 | section of zuul.conf. The location of the other two configuration |
| 33 | files (as well as the location of the PID file when running Zuul as a |
| 34 | server) are specified in a third section. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 35 | |
Clark Boylan | 9b67090 | 2012-09-28 13:47:56 -0700 | [diff] [blame] | 36 | The three sections of this config and their options are documented below. |
| 37 | You can also find an example zuul.conf file in the git |
| 38 | `repository |
K Jonathan Harker | 97e457e | 2013-02-26 13:29:38 -0800 | [diff] [blame] | 39 | <https://github.com/openstack-infra/zuul/blob/master/etc/zuul.conf-sample>`_ |
Clark Boylan | 9b67090 | 2012-09-28 13:47:56 -0700 | [diff] [blame] | 40 | |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 41 | gearman |
Clark Boylan | 9b67090 | 2012-09-28 13:47:56 -0700 | [diff] [blame] | 42 | """"""" |
| 43 | |
| 44 | **server** |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 45 | Hostname or IP address of the Gearman server. |
| 46 | ``server=gearman.example.com`` |
Clark Boylan | 9b67090 | 2012-09-28 13:47:56 -0700 | [diff] [blame] | 47 | |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 48 | **port** |
| 49 | Port on which the Gearman server is listening |
| 50 | ``port=4730`` |
Clark Boylan | 9b67090 | 2012-09-28 13:47:56 -0700 | [diff] [blame] | 51 | |
| 52 | gerrit |
| 53 | """""" |
| 54 | |
| 55 | **server** |
| 56 | FQDN of Gerrit server. |
| 57 | ``server=review.example.com`` |
| 58 | |
Antoine Musso | 2747501 | 2012-11-26 09:53:01 +0100 | [diff] [blame] | 59 | **baseurl** |
| 60 | Optional: path to Gerrit web interface. Defaults to ``https://<value |
| 61 | of server>/``. ``baseurl=https://review.example.com/review_site/`` |
| 62 | |
Clark Boylan | 9b67090 | 2012-09-28 13:47:56 -0700 | [diff] [blame] | 63 | **user** |
| 64 | User name to use when logging into above server via ssh. |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 65 | ``user=zuul`` |
Clark Boylan | 9b67090 | 2012-09-28 13:47:56 -0700 | [diff] [blame] | 66 | |
| 67 | **sshkey** |
| 68 | Path to SSH key to use when logging into above server. |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 69 | ``sshkey=/home/zuul/.ssh/id_rsa`` |
Clark Boylan | 9b67090 | 2012-09-28 13:47:56 -0700 | [diff] [blame] | 70 | |
| 71 | zuul |
| 72 | """" |
| 73 | |
| 74 | **layout_config** |
| 75 | Path to layout config file. |
| 76 | ``layout_config=/etc/zuul/layout.yaml`` |
| 77 | |
| 78 | **log_config** |
| 79 | Path to log config file. |
| 80 | ``log_config=/etc/zuul/logging.yaml`` |
| 81 | |
| 82 | **pidfile** |
| 83 | Path to PID lock file. |
| 84 | ``pidfile=/var/run/zuul/zuul.pid`` |
| 85 | |
| 86 | **state_dir** |
| 87 | Path to directory that Zuul should save state to. |
| 88 | ``state_dir=/var/lib/zuul`` |
| 89 | |
| 90 | **git_dir** |
| 91 | Directory that Zuul should clone local git repositories to. |
| 92 | ``git_dir=/var/lib/zuul/git`` |
| 93 | |
Paul Belanger | b67aba1 | 2013-05-13 19:22:14 -0400 | [diff] [blame] | 94 | **git_user_email** |
| 95 | Optional: Value to pass to `git config user.email`. |
| 96 | ``git_user_email=zuul@example.com`` |
| 97 | |
| 98 | **git_user_name** |
| 99 | Optional: Value to pass to `git config user.name`. |
| 100 | ``git_user_name=zuul`` |
| 101 | |
Clark Boylan | 9b67090 | 2012-09-28 13:47:56 -0700 | [diff] [blame] | 102 | **push_change_refs** |
| 103 | Boolean value (``true`` or ``false``) that determines if Zuul should |
| 104 | push change refs to the git origin server for the git repositories in |
| 105 | git_dir. |
| 106 | ``push_change_refs=true`` |
| 107 | |
James E. Blair | 0ac6c01 | 2013-04-26 09:04:23 -0700 | [diff] [blame] | 108 | **report_times** |
| 109 | Boolean value (``true`` or ``false``) that determines if Zuul should |
| 110 | include elapsed times for each job in the textual report. |
| 111 | ``report_times=true`` |
| 112 | |
Clark Boylan | 9b67090 | 2012-09-28 13:47:56 -0700 | [diff] [blame] | 113 | **status_url** |
| 114 | URL that will be posted in Zuul comments made to Gerrit changes when |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 115 | starting jobs for a change. |
| 116 | ``status_url=https://zuul.example.com/status`` |
Clark Boylan | 9b67090 | 2012-09-28 13:47:56 -0700 | [diff] [blame] | 117 | |
| 118 | **url_pattern** |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 119 | If you are storing build logs external to the system that originally |
| 120 | ran jobs and wish to link to those logs when Zuul makes comments on |
| 121 | Gerrit changes for completed jobs this setting configures what the |
| 122 | URLs for those links should be. |
Clark Boylan | 9b67090 | 2012-09-28 13:47:56 -0700 | [diff] [blame] | 123 | ``http://logs.example.com/{change.number}/{change.patchset}/{pipeline.name}/{job.name}/{build.number}`` |
| 124 | |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 125 | layout.yaml |
| 126 | ~~~~~~~~~~~ |
| 127 | |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 128 | This is the main configuration file for Zuul, where all of the pipelines |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 129 | and projects are defined, what tests should be run, and what actions |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 130 | Zuul should perform. There are three sections: pipelines, jobs, and |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 131 | projects. |
| 132 | |
James E. Blair | e5a847f | 2012-07-10 15:29:14 -0700 | [diff] [blame] | 133 | .. _includes: |
| 134 | |
| 135 | Includes |
| 136 | """""""" |
| 137 | |
| 138 | Custom functions to be used in Zuul's configuration may be provided |
| 139 | using the ``includes`` directive. It accepts a list of files to |
| 140 | include, and currently supports one type of inclusion, a python file:: |
| 141 | |
| 142 | includes: |
| 143 | - python-file: local_functions.py |
| 144 | |
| 145 | **python-file** |
| 146 | The path to a python file. The file will be loaded and objects that |
| 147 | it defines will be placed in a special environment which can be |
| 148 | referenced in the Zuul configuration. Currently only the |
| 149 | parameter-function attribute of a Job uses this feature. |
| 150 | |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 151 | Pipelines |
| 152 | """"""""" |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 153 | |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 154 | Zuul can have any number of independent pipelines. Whenever a matching |
| 155 | Gerrit event is found for a pipeline, that event is added to the |
| 156 | pipeline, and the jobs specified for that pipeline are run. When all |
| 157 | jobs specified for the pipeline that were triggered by an event are |
| 158 | completed, Zuul reports back to Gerrit the results. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 159 | |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 160 | There are no pre-defined pipelines in Zuul, rather you can define |
| 161 | whatever pipelines you need in the layout file. This is a very flexible |
| 162 | system that can accommodate many kinds of workflows. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 163 | |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 164 | Here is a quick example of a pipeline definition followed by an |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 165 | explanation of each of the parameters:: |
| 166 | |
| 167 | - name: check |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 168 | manager: IndependentPipelineManager |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 169 | trigger: |
| 170 | - event: patchset-created |
| 171 | success: |
| 172 | verified: 1 |
| 173 | failure: |
| 174 | verified: -1 |
| 175 | |
| 176 | **name** |
| 177 | This is used later in the project definition to indicate what jobs |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 178 | should be run for events in the pipeline. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 179 | |
James E. Blair | 8dbd56a | 2012-12-22 10:55:10 -0800 | [diff] [blame] | 180 | **description** |
| 181 | This is an optional field that may be used to provide a textual |
| 182 | description of the pipeline. |
| 183 | |
James E. Blair | 5637019 | 2013-01-14 15:47:28 -0800 | [diff] [blame] | 184 | **success-message** |
| 185 | An optional field that supplies the introductory text in message |
| 186 | reported back to Gerrit when all the voting builds are successful. |
| 187 | Defaults to "Build successful." |
| 188 | |
| 189 | **failure-message** |
| 190 | An optional field that supplies the introductory text in message |
| 191 | reported back to Gerrit when at least one voting build fails. |
| 192 | Defaults to "Build failed." |
| 193 | |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 194 | **manager** |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 195 | There are currently two schemes for managing pipelines: |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 196 | |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 197 | *IndependentPipelineManager* |
| 198 | Every event in this pipeline should be treated as independent of |
| 199 | other events in the pipeline. This is appropriate when the order of |
| 200 | events in the pipeline doesn't matter because the results of the |
| 201 | actions this pipeline performs can not affect other events in the |
| 202 | pipeline. For example, when a change is first uploaded for review, |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 203 | you may want to run tests on that change to provide early feedback |
| 204 | to reviewers. At the end of the tests, the change is not going to |
| 205 | be merged, so it is safe to run these tests in parallel without |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 206 | regard to any other changes in the pipeline. They are independent. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 207 | |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 208 | Another type of pipeline that is independent is a post-merge |
| 209 | pipeline. In that case, the changes have already merged, so the |
| 210 | results can not affect any other events in the pipeline. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 211 | |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 212 | *DependentPipelineManager* |
| 213 | The dependent pipeline manager is designed for gating. It ensures |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 214 | that every change is tested exactly as it is going to be merged |
| 215 | into the repository. An ideal gating system would test one change |
| 216 | at a time, applied to the tip of the repository, and only if that |
| 217 | change passed tests would it be merged. Then the next change in |
| 218 | line would be tested the same way. In order to achieve parallel |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 219 | testing of changes, the dependent pipeline manager performs |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 220 | speculative execution on changes. It orders changes based on |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 221 | their entry into the pipeline. It begins testing all changes in |
| 222 | parallel, assuming that each change ahead in the pipeline will pass |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 223 | its tests. If they all succeed, all the changes can be tested and |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 224 | merged in parallel. If a change near the front of the pipeline |
| 225 | fails its tests, each change behind it ignores whatever tests have |
| 226 | been completed and are tested again without the change in front. |
| 227 | This way gate tests may run in parallel but still be tested |
| 228 | correctly, exactly as they will appear in the repository when |
| 229 | merged. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 230 | |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 231 | One important characteristic of the DependentPipelineManager is that |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 232 | it analyzes the jobs that are triggered by different projects, and |
| 233 | if those projects have jobs in common, it treats those projects as |
| 234 | related, and they share a single virtual queue of changes. Thus, |
| 235 | if there is a job that performs integration testing on two |
| 236 | projects, those two projects will automatically share a virtual |
| 237 | change queue. If a third project does not invoke that job, it |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 238 | will be part of a separate virtual change queue, and changes to |
| 239 | it will not depend on changes to the first two jobs. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 240 | |
| 241 | For more detail on the theory and operation of Zuul's |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 242 | DependentPipelineManager, see: :doc:`gating`. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 243 | |
| 244 | **trigger** |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 245 | This describes what Gerrit events should be placed in the pipeline. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 246 | Triggers are not exclusive -- matching events may be placed in |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 247 | multiple pipelines, and they will behave independently in each of the |
| 248 | pipelines they match. Multiple triggers may be listed. Further |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 249 | parameters describe the kind of events that match: |
| 250 | |
| 251 | *event* |
| 252 | The event name from gerrit. Examples: ``patchset-created``, |
| 253 | ``comment-added``, ``ref-updated``. This field is treated as a |
| 254 | regular expression. |
| 255 | |
| 256 | *branch* |
| 257 | The branch associated with the event. Example: ``master``. This |
| 258 | field is treated as a regular expression, and multiple branches may |
| 259 | be listed. |
| 260 | |
| 261 | *ref* |
| 262 | On ref-updated events, the branch parameter is not used, instead the |
| 263 | ref is provided. Currently Gerrit has the somewhat idiosyncratic |
| 264 | behavior of specifying bare refs for branch names (e.g., ``master``), |
| 265 | but full ref names for other kinds of refs (e.g., ``refs/tags/foo``). |
| 266 | Zuul matches what you put here exactly against what Gerrit |
| 267 | provides. This field is treated as a regular expression, and |
| 268 | multiple refs may be listed. |
| 269 | |
| 270 | *approval* |
| 271 | This is only used for ``comment-added`` events. It only matches if |
| 272 | the event has a matching approval associated with it. Example: |
| 273 | ``code-review: 2`` matches a ``+2`` vote on the code review category. |
| 274 | Multiple approvals may be listed. |
| 275 | |
Antoine Musso | b4e809e | 2012-12-06 16:58:06 +0100 | [diff] [blame] | 276 | *email_filter* |
| 277 | This is used for any event. It takes a regex applied on the performer |
Antoine Musso | 5f11042 | 2012-12-18 23:22:13 +0100 | [diff] [blame] | 278 | email, i.e Gerrit account email address. If you want to specify |
| 279 | several email filters, you must use a YAML list. Make sure to use non |
| 280 | greedy matchers and to escapes dots! |
| 281 | Example: ``email_filter: ^.*?@example\.org$``. |
Antoine Musso | b4e809e | 2012-12-06 16:58:06 +0100 | [diff] [blame] | 282 | |
Clark Boylan | b9bcb40 | 2012-06-29 17:44:05 -0700 | [diff] [blame] | 283 | *comment_filter* |
| 284 | This is only used for ``comment-added`` events. It accepts a list of |
| 285 | regexes that are searched for in the comment string. If any of these |
| 286 | regexes matches a portion of the comment string the trigger is |
| 287 | matched. ``comment_filter: retrigger`` will match when comments |
| 288 | containing 'retrigger' somewhere in the comment text are added to a |
| 289 | change. |
| 290 | |
James E. Blair | 2fa5096 | 2013-01-30 21:50:41 -0800 | [diff] [blame] | 291 | **dequeue-on-new-patchset** |
| 292 | Normally, if a new patchset is uploaded to a change that is in a |
| 293 | pipeline, the existing entry in the pipeline will be removed (with |
| 294 | jobs canceled and any dependent changes that can no longer merge as |
| 295 | well. To suppress this behavior (and allow jobs to continue |
| 296 | running), set this to ``false``. Default: ``true``. |
| 297 | |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 298 | **success** |
| 299 | Describes what Zuul should do if all the jobs complete successfully. |
| 300 | This section is optional; if it is omitted, Zuul will run jobs and |
| 301 | do nothing on success; it will not even report a message to Gerrit. |
| 302 | If the section is present, it will leave a message on the Gerrit |
| 303 | review. Each additional argument is assumed to be an argument to |
| 304 | ``gerrit review``, with the boolean value of ``true`` simply |
| 305 | indicating that the argument should be present without following it |
| 306 | with a value. For example, ``verified: 1`` becomes ``gerrit |
| 307 | review --verified 1`` and ``submit: true`` becomes ``gerrit review |
| 308 | --submit``. |
| 309 | |
Mathieu Gagné | d6d2a64 | 2013-06-11 20:59:58 -0400 | [diff] [blame] | 310 | **failure** |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 311 | Uses the same syntax as **success**, but describes what Zuul should |
| 312 | do if at least one job fails. |
James E. Blair | dc25386 | 2012-06-13 17:12:42 -0700 | [diff] [blame] | 313 | |
Mathieu Gagné | d6d2a64 | 2013-06-11 20:59:58 -0400 | [diff] [blame] | 314 | **start** |
James E. Blair | dc25386 | 2012-06-13 17:12:42 -0700 | [diff] [blame] | 315 | Uses the same syntax as **success**, but describes what Zuul should |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 316 | do when a change is added to the pipeline manager. This can be used, |
James E. Blair | dc25386 | 2012-06-13 17:12:42 -0700 | [diff] [blame] | 317 | for example, to reset the value of the Verified review category. |
Mathieu Gagné | d6d2a64 | 2013-06-11 20:59:58 -0400 | [diff] [blame] | 318 | |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 319 | Some example pipeline configurations are included in the sample layout |
| 320 | file. The first is called a *check* pipeline:: |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 321 | |
| 322 | - name: check |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 323 | manager: IndependentPipelineManager |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 324 | trigger: |
| 325 | - event: patchset-created |
| 326 | success: |
| 327 | verified: 1 |
| 328 | failure: |
| 329 | verified: -1 |
| 330 | |
| 331 | This will trigger jobs each time a new patchset (or change) is |
| 332 | uploaded to Gerrit, and report +/-1 values to Gerrit in the |
| 333 | ``verified`` review category. :: |
| 334 | |
| 335 | - name: gate |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 336 | manager: DependentPipelineManager |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 337 | trigger: |
| 338 | - event: comment-added |
| 339 | approval: |
| 340 | - approved: 1 |
| 341 | success: |
| 342 | verified: 2 |
| 343 | submit: true |
| 344 | failure: |
| 345 | verified: -2 |
| 346 | |
| 347 | This will trigger jobs whenever a reviewer leaves a vote of ``1`` in the |
| 348 | ``approved`` review category in Gerrit (a non-standard category). |
| 349 | Changes will be tested in such a way as to guarantee that they will be |
| 350 | merged exactly as tested, though that will happen in parallel by |
| 351 | creating a virtual queue of dependent changes and performing |
| 352 | speculative execution of jobs. :: |
| 353 | |
| 354 | - name: post |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 355 | manager: IndependentPipelineManager |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 356 | trigger: |
| 357 | - event: ref-updated |
| 358 | ref: ^(?!refs/).*$ |
| 359 | |
| 360 | This will trigger jobs whenever a change is merged to a named branch |
| 361 | (e.g., ``master``). No output will be reported to Gerrit. This is |
| 362 | useful for side effects such as creating per-commit tarballs. :: |
| 363 | |
| 364 | - name: silent |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 365 | manager: IndependentPipelineManager |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 366 | trigger: |
| 367 | - event: patchset-created |
| 368 | |
| 369 | This also triggers jobs when changes are uploaded to Gerrit, but no |
| 370 | results are reported to Gerrit. This is useful for jobs that are in |
Antoine Musso | ce33384 | 2012-10-16 14:42:35 +0200 | [diff] [blame] | 371 | development and not yet ready to be presented to developers. :: |
| 372 | |
| 373 | pipelines: |
| 374 | - name: post-merge |
| 375 | manager: IndependentPipelineManager |
| 376 | trigger: |
| 377 | - event: change-merged |
| 378 | success: |
| 379 | force-message: True |
| 380 | failure: |
| 381 | force-message: True |
| 382 | |
| 383 | The ``change-merged`` events happen when a change has been merged in the git |
| 384 | repository. The change is thus closed and Gerrit will not accept modifications |
| 385 | to the review scoring such as ``code-review`` or ``verified``. By using the |
| 386 | ``force-message: True`` parameter, Zuul will pass ``--force-message`` to the |
| 387 | ``gerrit review`` command, thus making sure the message is actually |
| 388 | sent back to Gerrit regardless of approval scores. |
| 389 | That kind of pipeline is nice to run regression or performance tests. |
| 390 | |
| 391 | .. note:: |
| 392 | The ``change-merged`` event does not include the commit sha1 which can be |
| 393 | hazardous, it would let you report back to Gerrit though. If you were to |
| 394 | build a tarball for a specific commit, you should consider insteading using |
| 395 | the ``ref-updated`` event which does include the commit sha1 (but lack the |
| 396 | Gerrit change number). |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 397 | |
| 398 | Jobs |
| 399 | """" |
| 400 | |
| 401 | The jobs section is optional, and can be used to set attributes of |
| 402 | jobs that are independent of their association with a project. For |
| 403 | example, if a job should return a customized message on failure, that |
| 404 | may be specified here. Otherwise, Zuul does not need to be told about |
| 405 | each job as it builds a list from the project specification. |
| 406 | |
| 407 | **name** |
| 408 | The name of the job. This field is treated as a regular expression |
| 409 | and will be applied to each job that matches. |
| 410 | |
James E. Blair | e5a847f | 2012-07-10 15:29:14 -0700 | [diff] [blame] | 411 | **failure-message (optional)** |
| 412 | The message that should be reported to Gerrit if the job fails. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 413 | |
James E. Blair | e5a847f | 2012-07-10 15:29:14 -0700 | [diff] [blame] | 414 | **success-message (optional)** |
| 415 | The message that should be reported to Gerrit if the job fails. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 416 | |
James E. Blair | 6aea36d | 2012-12-17 13:03:24 -0800 | [diff] [blame] | 417 | **failure-pattern (optional)** |
| 418 | The URL that should be reported to Gerrit if the job fails. |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 419 | Defaults to the build URL or the url_pattern configured in |
James E. Blair | 6aea36d | 2012-12-17 13:03:24 -0800 | [diff] [blame] | 420 | zuul.conf. May be supplied as a string pattern with substitutions |
| 421 | as described in url_pattern in :ref:`zuulconf`. |
| 422 | |
| 423 | **success-pattern (optional)** |
| 424 | The URL that should be reported to Gerrit if the job succeeds. |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 425 | Defaults to the build URL or the url_pattern configured in |
James E. Blair | 6aea36d | 2012-12-17 13:03:24 -0800 | [diff] [blame] | 426 | zuul.conf. May be supplied as a string pattern with substitutions |
| 427 | as described in url_pattern in :ref:`zuulconf`. |
| 428 | |
James E. Blair | 222d498 | 2012-07-16 09:31:19 -0700 | [diff] [blame] | 429 | **hold-following-changes (optional)** |
| 430 | This is a boolean that indicates that changes that follow this |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 431 | change in a dependent change pipeline should wait until this job |
James E. Blair | 222d498 | 2012-07-16 09:31:19 -0700 | [diff] [blame] | 432 | succeeds before launching. If this is applied to a very short job |
| 433 | that can predict whether longer jobs will fail early, this can be |
| 434 | used to reduce the number of jobs that Zuul will launch and |
| 435 | ultimately have to cancel. In that case, a small amount of |
Mathieu Gagné | d6d2a64 | 2013-06-11 20:59:58 -0400 | [diff] [blame] | 436 | parallelization of jobs is traded for more efficient use of testing |
James E. Blair | 222d498 | 2012-07-16 09:31:19 -0700 | [diff] [blame] | 437 | resources. On the other hand, to apply this to a long running job |
| 438 | would largely defeat the parallelization of dependent change testing |
Mathieu Gagné | d6d2a64 | 2013-06-11 20:59:58 -0400 | [diff] [blame] | 439 | that is the main feature of Zuul. Default: ``false``. |
James E. Blair | 222d498 | 2012-07-16 09:31:19 -0700 | [diff] [blame] | 440 | |
James E. Blair | e5a847f | 2012-07-10 15:29:14 -0700 | [diff] [blame] | 441 | **branch (optional)** |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 442 | This job should only be run on matching branches. This field is |
| 443 | treated as a regular expression and multiple branches may be |
| 444 | listed. |
| 445 | |
James E. Blair | 70c7158 | 2013-03-06 08:50:50 -0800 | [diff] [blame] | 446 | **files (optional)** |
| 447 | This job should only be run if at least one of the files involved in |
| 448 | the change (added, deleted, or modified) matches at least one of the |
| 449 | file patterns listed here. This field is treated as a regular |
| 450 | expression and multiple expressions may be listed. |
| 451 | |
Mathieu Gagné | d6d2a64 | 2013-06-11 20:59:58 -0400 | [diff] [blame] | 452 | **voting (optional)** |
| 453 | Boolean value (``true`` or ``false``) that indicates whatever |
| 454 | a job is voting or not. Default: ``true``. |
| 455 | |
James E. Blair | e5a847f | 2012-07-10 15:29:14 -0700 | [diff] [blame] | 456 | **parameter-function (optional)** |
| 457 | Specifies a function that should be applied to the parameters before |
| 458 | the job is launched. The function should be defined in a python file |
| 459 | included with the :ref:`includes` directive. The function |
| 460 | should have the following signature: |
| 461 | |
| 462 | .. function:: parameters(change, parameters) |
| 463 | |
| 464 | Manipulate the parameters passed to a job before a build is |
| 465 | launched. The ``parameters`` dictionary will already contain the |
| 466 | standard Zuul job parameters, and is expected to be modified |
| 467 | in-place. |
| 468 | |
| 469 | :param change: the current change |
| 470 | :type change: zuul.model.Change |
| 471 | :param parameters: parameters to be passed to the job |
| 472 | :type parameters: dict |
| 473 | |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 474 | If the parameter **ZUUL_NODE** is set by this function, then it will |
| 475 | be used to specify on what node (or class of node) the job should be |
| 476 | run. |
| 477 | |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 478 | Here is an example of setting the failure message for jobs that check |
| 479 | whether a change merges cleanly:: |
| 480 | |
| 481 | - name: ^.*-merge$ |
| 482 | failure-message: This change was unable to be automatically merged |
| 483 | with the current state of the repository. Please rebase your |
| 484 | change and upload a new patchset. |
| 485 | |
| 486 | Projects |
| 487 | """""""" |
| 488 | |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 489 | The projects section indicates what jobs should be run in each pipeline |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 490 | for events associated with each project. It contains a list of |
| 491 | projects. Here is an example:: |
| 492 | |
| 493 | - name: example/project |
| 494 | check: |
| 495 | - project-merge: |
| 496 | - project-unittest |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 497 | - project-pep8 |
| 498 | - project-pyflakes |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 499 | gate: |
| 500 | - project-merge: |
| 501 | - project-unittest |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 502 | - project-pep8 |
| 503 | - project-pyflakes |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 504 | post: |
| 505 | - project-publish |
| 506 | |
| 507 | **name** |
| 508 | The name of the project (as known by Gerrit). |
| 509 | |
Clark Boylan | 00635dc | 2012-09-19 14:03:08 -0700 | [diff] [blame] | 510 | This is followed by a section for each of the pipelines defined above. |
| 511 | Pipelines may be omitted if no jobs should run for this project in a |
| 512 | given pipeline. Within the pipeline section, the jobs that should be |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 513 | executed are listed. If a job is entered as a dictionary key, then |
| 514 | jobs contained within that key are only executed if the key job |
| 515 | succeeds. In the above example, project-unittest, project-pep8, and |
| 516 | project-pyflakes are only executed if project-merge succeeds. This |
| 517 | can help avoid running unnecessary jobs. |
| 518 | |
Paul Belanger | ffef9e4 | 2013-02-11 22:15:18 -0500 | [diff] [blame] | 519 | .. seealso:: The OpenStack Zuul configuration for a comprehensive example: https://github.com/openstack-infra/config/blob/master/modules/openstack_project/files/zuul/layout.yaml |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 520 | |
Antoine Musso | 80edd5a | 2013-02-13 15:37:53 +0100 | [diff] [blame] | 521 | Project Templates |
| 522 | """"""""""""""""" |
| 523 | |
| 524 | Whenever you have lot of similiar projects (such as plugins for a project) you |
| 525 | will most probably want to use the same pipeline configurations. The |
| 526 | project templates let you define pipelines and job name templates to trigger. |
| 527 | One can then just apply the template on its project which make it easier to |
| 528 | update several similiar projects. As an example:: |
| 529 | |
| 530 | project-templates: |
| 531 | # Name of the template |
| 532 | - name: plugin-triggering |
| 533 | # Definition of pipelines just like for a `project` |
| 534 | check: |
| 535 | - '{jobprefix}-merge': |
| 536 | - '{jobprefix}-pep8' |
| 537 | - '{jobprefix}-pyflakes' |
| 538 | gate: |
| 539 | - '{jobprefix}-merge': |
| 540 | - '{jobprefix}-unittest' |
| 541 | - '{jobprefix}-pep8' |
| 542 | - '{jobprefix}-pyflakes' |
| 543 | |
| 544 | In your projects definition, you will then apply the template using the template |
| 545 | key:: |
| 546 | |
| 547 | projects: |
| 548 | - name: plugin/foobar |
| 549 | template: |
| 550 | - name: plugin-triggering |
| 551 | jobprefix: plugin-foobar |
| 552 | |
| 553 | You can pass several parameters to a template. A ``parameter`` value will be |
| 554 | used for expansion of ``{parameter}`` in the template strings. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 555 | |
| 556 | logging.conf |
| 557 | ~~~~~~~~~~~~ |
| 558 | This file is optional. If provided, it should be a standard |
| 559 | :mod:`logging.config` module configuration file. If not present, Zuul will |
| 560 | output all log messages of DEBUG level or higher to the console. |
| 561 | |
| 562 | Starting Zuul |
| 563 | ------------- |
| 564 | |
| 565 | To start Zuul, run **zuul-server**:: |
| 566 | |
Antoine Musso | b3aa828 | 2013-04-19 15:16:59 +0200 | [diff] [blame] | 567 | usage: zuul-server [-h] [-c CONFIG] [-l LAYOUT] [-d] [-t] [--version] |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 568 | |
| 569 | Project gating system. |
| 570 | |
| 571 | optional arguments: |
| 572 | -h, --help show this help message and exit |
| 573 | -c CONFIG specify the config file |
Antoine Musso | b3aa828 | 2013-04-19 15:16:59 +0200 | [diff] [blame] | 574 | -l LAYOUT specify the layout file |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 575 | -d do not run as a daemon |
Antoine Musso | b3aa828 | 2013-04-19 15:16:59 +0200 | [diff] [blame] | 576 | -t validate layout file syntax |
| 577 | --version show zuul version |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 578 | |
| 579 | You may want to use the ``-d`` argument while you are initially setting |
| 580 | up Zuul so you can detect any configuration errors quickly. Under |
| 581 | normal operation, omit ``-d`` and let Zuul run as a daemon. |
| 582 | |
| 583 | If you send signal 1 (SIGHUP) to the zuul-server process, Zuul will |
| 584 | stop executing new jobs, wait until all executing jobs are finished, |
| 585 | reload its configuration, and resume. Any values in any of the |
| 586 | configuration files may be changed, except the location of Zuul's PID |
| 587 | file (a change to that will be ignored until Zuul is restarted). |
Clark Boylan | f231fa2 | 2013-02-08 12:28:53 -0800 | [diff] [blame] | 588 | |
| 589 | If you send a SIGUSR1 to the zuul-server process, Zuul will stop |
| 590 | executing new jobs, wait until all executing jobs are finished, |
| 591 | then exit. While waiting to exit Zuul will queue Gerrit events and |
| 592 | save these events prior to exiting. When Zuul starts again it will |
| 593 | read these saved events and act on them. |
Jeremy Stanley | 93e05f4 | 2013-03-08 17:29:17 +0000 | [diff] [blame] | 594 | |
| 595 | If you need to abort zuul and intend to manually requeue changes for |
| 596 | jobs which were running in its pipelines, prior to terminating you can |
| 597 | use the zuul-changes.py tool script to simplify the process. For |
| 598 | example, this would give you a list of Gerrit commands to reverify or |
| 599 | recheck changes for the gate and check pipelines respectively:: |
| 600 | |
| 601 | ./tools/zuul-changes.py --review-host=review.openstack.org \ |
| 602 | http://zuul.openstack.org/ gate 'reverify no bug' |
| 603 | ./tools/zuul-changes.py --review-host=review.openstack.org \ |
| 604 | http://zuul.openstack.org/ check 'recheck no bug' |