James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 1 | :title: Project Configuration |
| 2 | |
| 3 | .. _project-config: |
| 4 | |
| 5 | Project Configuration |
| 6 | ===================== |
| 7 | |
| 8 | The following sections describe the main part of Zuul's configuration. |
| 9 | All of what follows is found within files inside of the repositories |
| 10 | that Zuul manages. |
| 11 | |
| 12 | Security Contexts |
| 13 | ----------------- |
| 14 | |
| 15 | When a system administrator configures Zuul to operate on a project, |
| 16 | they specify one of two security contexts for that project. A |
| 17 | *config-project* is one which is primarily tasked with holding |
| 18 | configuration information and job content for Zuul. Jobs which are |
| 19 | defined in a *config-project* are run with elevated privileges, and |
| 20 | all Zuul configuration items are available for use. It is expected |
| 21 | that changes to *config-projects* will undergo careful scrutiny before |
| 22 | being merged. |
| 23 | |
| 24 | An *untrusted-project* is a project whose primary focus is not to |
| 25 | operate Zuul, but rather it is one of the projects being tested or |
| 26 | deployed. The Zuul configuration language available to these projects |
| 27 | is somewhat restricted (as detailed in individual section below), and |
| 28 | jobs defined in these projects run in a restricted execution |
| 29 | environment since they may be operating on changes which have not yet |
| 30 | undergone review. |
| 31 | |
| 32 | Configuration Loading |
| 33 | --------------------- |
| 34 | |
| 35 | When Zuul starts, it examines all of the git repositories which are |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 36 | specified by the system administrator in :ref:`tenant-config` and searches |
Tristan Cacqueray | 4a01583 | 2017-07-11 05:18:14 +0000 | [diff] [blame] | 37 | for files in the root of each repository. Zuul looks first for a file named |
| 38 | `zuul.yaml` or a directory named `zuul.d`, and if they are not found, |
| 39 | `.zuul.yaml` or `.zuul.d` (with a leading dot). In the case of an |
| 40 | *untrusted-project*, the configuration from every branch is included, |
| 41 | however, in the case of a *config-project*, only the `master` branch is |
| 42 | examined. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 43 | |
| 44 | When a change is proposed to one of these files in an |
| 45 | *untrusted-project*, the configuration proposed in the change is |
| 46 | merged into the running configuration so that any changes to Zuul's |
| 47 | configuration are self-testing as part of that change. If there is a |
| 48 | configuration error, no jobs will be run and the error will be |
| 49 | reported by any applicable pipelines. In the case of a change to a |
| 50 | *config-project*, the new configuration is parsed and examined for |
| 51 | errors, but the new configuration is not used in testing the change. |
| 52 | This is because configuration in *config-projects* is able to access |
| 53 | elevated privileges and should always be reviewed before being merged. |
| 54 | |
| 55 | As soon as a change containing a Zuul configuration change merges to |
| 56 | any Zuul-managed repository, the new configuration takes effect |
| 57 | immediately. |
| 58 | |
| 59 | Configuration Items |
| 60 | ------------------- |
| 61 | |
| 62 | The `zuul.yaml` and `.zuul.yaml` configuration files are |
| 63 | YAML-formatted and are structured as a series of items, each of which |
| 64 | is described below. |
| 65 | |
Tristan Cacqueray | 4a01583 | 2017-07-11 05:18:14 +0000 | [diff] [blame] | 66 | In the case of a `zuul.d` directory, Zuul recurses the directory and extends |
| 67 | the configuration using all the .yaml files in the sorted path order. |
| 68 | For example, to keep job's variants in a separate file, it needs to be loaded |
| 69 | after the main entries, for example using number prefixes in file's names:: |
| 70 | |
| 71 | * zuul.d/pipelines.yaml |
| 72 | * zuul.d/projects.yaml |
| 73 | * zuul.d/01_jobs.yaml |
| 74 | * zuul.d/02_jobs-variants.yaml |
| 75 | |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 76 | .. _pipeline: |
| 77 | |
| 78 | Pipeline |
| 79 | ~~~~~~~~ |
| 80 | |
| 81 | A pipeline describes a workflow operation in Zuul. It associates jobs |
| 82 | for a given project with triggering and reporting events. |
| 83 | |
| 84 | Its flexible configuration allows for characterizing any number of |
| 85 | workflows, and by specifying each as a named configuration, makes it |
| 86 | easy to apply similar workflow operations to projects or groups of |
| 87 | projects. |
| 88 | |
| 89 | By way of example, one of the primary uses of Zuul is to perform |
| 90 | project gating. To do so, one can create a *gate* pipeline which |
| 91 | tells Zuul that when a certain event (such as approval by a code |
| 92 | reviewer) occurs, the corresponding change or pull request should be |
| 93 | enqueued into the pipeline. When that happens, the jobs which have |
| 94 | been configured to run for that project in the *gate* pipeline are |
| 95 | run, and when they complete, the pipeline reports the results to the |
| 96 | user. |
| 97 | |
| 98 | Pipeline configuration items may only appear in *config-projects*. |
| 99 | |
| 100 | Generally, a Zuul administrator would define a small number of |
| 101 | pipelines which represent the workflow processes used in their |
| 102 | environment. Each project can then be added to the available |
| 103 | pipelines as appropriate. |
| 104 | |
| 105 | Here is an example *check* pipeline, which runs whenever a new |
| 106 | patchset is created in Gerrit. If the associated jobs all report |
| 107 | success, the pipeline reports back to Gerrit with a *Verified* vote of |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 108 | +1, or if at least one of them fails, a -1: |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 109 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 110 | .. code-block:: yaml |
| 111 | |
| 112 | - pipeline: |
| 113 | name: check |
| 114 | manager: independent |
| 115 | trigger: |
| 116 | my_gerrit: |
| 117 | - event: patchset-created |
| 118 | success: |
| 119 | my_gerrit: |
| 120 | Verified: 1 |
| 121 | failure: |
| 122 | my_gerrit |
| 123 | Verified: -1 |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 124 | |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 125 | .. TODO: See TODO for more annotated examples of common pipeline configurations. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 126 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 127 | .. attr:: pipeline |
James E. Blair | 7145c58 | 2017-07-26 13:30:39 -0700 | [diff] [blame] | 128 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 129 | The attributes available on a pipeline are as follows (all are |
| 130 | optional unless otherwise specified): |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 131 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 132 | .. attr:: name |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 133 | :required: |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 134 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 135 | This is used later in the project definition to indicate what jobs |
| 136 | should be run for events in the pipeline. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 137 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 138 | .. attr:: manager |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 139 | :required: |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 140 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 141 | There are currently two schemes for managing pipelines: |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 142 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 143 | .. value:: independent |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 144 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 145 | Every event in this pipeline should be treated as independent |
| 146 | of other events in the pipeline. This is appropriate when |
| 147 | the order of events in the pipeline doesn't matter because |
| 148 | the results of the actions this pipeline performs can not |
| 149 | affect other events in the pipeline. For example, when a |
| 150 | change is first uploaded for review, you may want to run |
| 151 | tests on that change to provide early feedback to reviewers. |
| 152 | At the end of the tests, the change is not going to be |
| 153 | merged, so it is safe to run these tests in parallel without |
| 154 | regard to any other changes in the pipeline. They are |
| 155 | independent. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 156 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 157 | Another type of pipeline that is independent is a post-merge |
| 158 | pipeline. In that case, the changes have already merged, so |
| 159 | the results can not affect any other events in the pipeline. |
James E. Blair | 1761e86 | 2017-07-25 16:15:47 -0700 | [diff] [blame] | 160 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 161 | .. value:: dependent |
James E. Blair | 1761e86 | 2017-07-25 16:15:47 -0700 | [diff] [blame] | 162 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 163 | The dependent pipeline manager is designed for gating. It |
| 164 | ensures that every change is tested exactly as it is going to |
| 165 | be merged into the repository. An ideal gating system would |
| 166 | test one change at a time, applied to the tip of the |
| 167 | repository, and only if that change passed tests would it be |
| 168 | merged. Then the next change in line would be tested the |
| 169 | same way. In order to achieve parallel testing of changes, |
| 170 | the dependent pipeline manager performs speculative execution |
| 171 | on changes. It orders changes based on their entry into the |
| 172 | pipeline. It begins testing all changes in parallel, |
| 173 | assuming that each change ahead in the pipeline will pass its |
| 174 | tests. If they all succeed, all the changes can be tested |
| 175 | and merged in parallel. If a change near the front of the |
| 176 | pipeline fails its tests, each change behind it ignores |
| 177 | whatever tests have been completed and are tested again |
| 178 | without the change in front. This way gate tests may run in |
| 179 | parallel but still be tested correctly, exactly as they will |
| 180 | appear in the repository when merged. |
James E. Blair | 1761e86 | 2017-07-25 16:15:47 -0700 | [diff] [blame] | 181 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 182 | For more detail on the theory and operation of Zuul's |
| 183 | dependent pipeline manager, see: :doc:`gating`. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 184 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 185 | .. attr:: allow-secrets |
James E. Blair | f17aa9c | 2017-07-05 13:21:23 -0700 | [diff] [blame] | 186 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 187 | This is a boolean which can be used to prevent jobs which |
| 188 | require secrets from running in this pipeline. Some pipelines |
| 189 | run on proposed changes and therefore execute code which has not |
| 190 | yet been reviewed. In such a case, allowing a job to use a |
| 191 | secret could result in that secret being exposed. The default |
| 192 | is False, meaning that in order to run jobs with secrets, this |
| 193 | must be explicitly enabled on each Pipeline where that is safe. |
James E. Blair | f17aa9c | 2017-07-05 13:21:23 -0700 | [diff] [blame] | 194 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 195 | For more information, see :ref:`secret`. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 196 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 197 | .. attr:: description |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 198 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 199 | This field may be used to provide a textual description of the |
| 200 | pipeline. It may appear in the status page or in documentation. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 201 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 202 | .. attr:: success-message |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 203 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 204 | The introductory text in reports when all the voting jobs are |
| 205 | successful. Defaults to "Build successful." |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 206 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 207 | .. attr:: failure-message |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 208 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 209 | The introductory text in reports when at least one voting job |
| 210 | fails. Defaults to "Build failed." |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 211 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 212 | .. attr:: merge-failure-message |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 213 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 214 | The introductory text in the message reported when a change |
| 215 | fails to merge with the current state of the repository. |
| 216 | Defaults to "Merge failed." |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 217 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 218 | .. attr:: footer-message |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 219 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 220 | Supplies additional information after test results. Useful for |
| 221 | adding information about the CI system such as debugging and |
| 222 | contact details. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 223 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 224 | .. attr:: trigger |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 225 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 226 | At least one trigger source must be supplied for each pipeline. |
| 227 | Triggers are not exclusive -- matching events may be placed in |
| 228 | multiple pipelines, and they will behave independently in each |
| 229 | of the pipelines they match. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 230 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 231 | Triggers are loaded from their connection name. The driver type |
| 232 | of the connection will dictate which options are available. See |
| 233 | :ref:`drivers`. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 234 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 235 | .. attr:: require |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 236 | |
James E. Blair | d134c6d | 2017-07-26 16:09:34 -0700 | [diff] [blame] | 237 | If this section is present, it establishes pre-requisites for |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 238 | any kind of item entering the Pipeline. Regardless of how the |
| 239 | item is to be enqueued (via any trigger or automatic dependency |
| 240 | resolution), the conditions specified here must be met or the |
James E. Blair | d134c6d | 2017-07-26 16:09:34 -0700 | [diff] [blame] | 241 | item will not be enqueued. These requirements may vary |
| 242 | depending on the source of the item being enqueued. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 243 | |
James E. Blair | d134c6d | 2017-07-26 16:09:34 -0700 | [diff] [blame] | 244 | Requirements are loaded from their connection name. The driver |
| 245 | type of the connection will dictate which options are available. |
| 246 | See :ref:`drivers`. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 247 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 248 | .. attr:: reject |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 249 | |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 250 | If this section is present, it establishes pre-requisites that |
| 251 | can block an item from being enqueued. It can be considered a |
| 252 | negative version of **require**. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 253 | |
James E. Blair | d134c6d | 2017-07-26 16:09:34 -0700 | [diff] [blame] | 254 | Requirements are loaded from their connection name. The driver |
| 255 | type of the connection will dictate which options are available. |
| 256 | See :ref:`drivers`. |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 257 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 258 | .. attr:: dequeue-on-new-patchset |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 259 | |
| 260 | Normally, if a new patchset is uploaded to a change that is in a |
| 261 | pipeline, the existing entry in the pipeline will be removed |
| 262 | (with jobs canceled and any dependent changes that can no longer |
| 263 | merge as well. To suppress this behavior (and allow jobs to |
| 264 | continue running), set this to ``false``. Default: ``true``. |
| 265 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 266 | .. attr:: ignore-dependencies |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 267 | |
| 268 | In any kind of pipeline (dependent or independent), Zuul will |
| 269 | attempt to enqueue all dependencies ahead of the current change |
| 270 | so that they are tested together (independent pipelines report |
| 271 | the results of each change regardless of the results of changes |
| 272 | ahead). To ignore dependencies completely in an independent |
| 273 | pipeline, set this to ``true``. This option is ignored by |
| 274 | dependent pipelines. The default is: ``false``. |
| 275 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 276 | .. attr:: precedence |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 277 | |
| 278 | Indicates how the build scheduler should prioritize jobs for |
| 279 | different pipelines. Each pipeline may have one precedence, |
| 280 | jobs for pipelines with a higher precedence will be run before |
| 281 | ones with lower. The value should be one of ``high``, |
| 282 | ``normal``, or ``low``. Default: ``normal``. |
| 283 | |
| 284 | The following options configure *reporters*. Reporters are |
| 285 | complementary to triggers; where a trigger is an event on a |
| 286 | connection which causes Zuul to enqueue an item, a reporter is the |
| 287 | action performed on a connection when an item is dequeued after its |
| 288 | jobs complete. The actual syntax for a reporter is defined by the |
| 289 | driver which implements it. See :ref:`drivers` for more |
| 290 | information. |
| 291 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 292 | .. attr:: success |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 293 | |
| 294 | Describes where Zuul should report to if all the jobs complete |
| 295 | successfully. This section is optional; if it is omitted, Zuul |
| 296 | will run jobs and do nothing on success -- it will not report at |
| 297 | all. If the section is present, the listed reporters will be |
| 298 | asked to report on the jobs. The reporters are listed by their |
| 299 | connection name. The options available depend on the driver for |
| 300 | the supplied connection. |
| 301 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 302 | .. attr:: failure |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 303 | |
| 304 | These reporters describe what Zuul should do if at least one job |
| 305 | fails. |
| 306 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 307 | .. attr:: merge-failure |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 308 | |
| 309 | These reporters describe what Zuul should do if it is unable to |
| 310 | merge in the patchset. If no merge-failure reporters are listed |
| 311 | then the ``failure`` reporters will be used to notify of |
| 312 | unsuccessful merges. |
| 313 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 314 | .. attr:: start |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 315 | |
| 316 | These reporters describe what Zuul should do when a change is |
| 317 | added to the pipeline. This can be used, for example, to reset |
| 318 | a previously reported result. |
| 319 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 320 | .. attr:: disabled |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 321 | |
| 322 | These reporters describe what Zuul should do when a pipeline is |
| 323 | disabled. See ``disable-after-consecutive-failures``. |
| 324 | |
| 325 | The following options can be used to alter Zuul's behavior to |
| 326 | mitigate situations in which jobs are failing frequently (perhaps |
| 327 | due to a problem with an external dependency, or unusually high |
| 328 | non-deterministic test failures). |
| 329 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 330 | .. attr:: disable-after-consecutive-failures |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 331 | |
| 332 | If set, a pipeline can enter a ''disabled'' state if too many |
| 333 | changes in a row fail. When this value is exceeded the pipeline |
| 334 | will stop reporting to any of the ``success``, ``failure`` or |
| 335 | ``merge-failure`` reporters and instead only report to the |
| 336 | ``disabled`` reporters. (No ``start`` reports are made when a |
| 337 | pipeline is disabled). |
| 338 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 339 | .. attr:: window |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 340 | |
| 341 | Dependent pipeline managers only. Zuul can rate limit dependent |
| 342 | pipelines in a manner similar to TCP flow control. Jobs are |
| 343 | only started for items in the queue if they are within the |
| 344 | actionable window for the pipeline. The initial length of this |
| 345 | window is configurable with this value. The value given should |
| 346 | be a positive integer value. A value of ``0`` disables rate |
| 347 | limiting on the DependentPipelineManager. Default: ``20``. |
| 348 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 349 | .. attr:: window-floor |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 350 | |
| 351 | Dependent pipeline managers only. This is the minimum value for |
| 352 | the window described above. Should be a positive non zero |
| 353 | integer value. Default: ``3``. |
| 354 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 355 | .. attr:: window-increase-type |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 356 | |
| 357 | Dependent pipeline managers only. This value describes how the |
| 358 | window should grow when changes are successfully merged by |
| 359 | zuul. A value of ``linear`` indicates that |
| 360 | ``window-increase-factor`` should be added to the previous |
| 361 | window value. A value of ``exponential`` indicates that |
| 362 | ``window-increase-factor`` should be multiplied against the |
| 363 | previous window value and the result will become the window |
| 364 | size. Default: ``linear``. |
| 365 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 366 | .. attr:: window-increase-factor |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 367 | |
| 368 | Dependent pipeline managers only. The value to be added or |
| 369 | multiplied against the previous window value to determine the |
| 370 | new window after successful change merges. Default: ``1``. |
| 371 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 372 | .. attr:: window-decrease-type |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 373 | |
| 374 | Dependent pipeline managers only. This value describes how the |
| 375 | window should shrink when changes are not able to be merged by |
| 376 | Zuul. A value of ``linear`` indicates that |
| 377 | ``window-decrease-factor`` should be subtracted from the |
| 378 | previous window value. A value of ``exponential`` indicates that |
| 379 | ``window-decrease-factor`` should be divided against the |
| 380 | previous window value and the result will become the window |
| 381 | size. Default: ``exponential``. |
| 382 | |
James E. Blair | 9437591 | 2017-07-28 17:20:27 -0700 | [diff] [blame] | 383 | .. attr:: window-decrease-factor |
James E. Blair | 9fd98ab | 2017-07-26 14:15:26 -0700 | [diff] [blame] | 384 | |
| 385 | Dependent pipline managers only. The value to be subtracted or |
| 386 | divided against the previous window value to determine the new |
| 387 | window after unsuccessful change merges. Default: ``2``. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 388 | |
| 389 | |
| 390 | .. _job: |
| 391 | |
| 392 | Job |
| 393 | ~~~ |
| 394 | |
| 395 | A job is a unit of work performed by Zuul on an item enqueued into a |
| 396 | pipeline. Items may run any number of jobs (which may depend on each |
| 397 | other). Each job is an invocation of an Ansible playbook with a |
| 398 | specific inventory of hosts. The actual tasks that are run by the job |
| 399 | appear in the playbook for that job while the attributes that appear in the |
| 400 | Zuul configuration specify information about when, where, and how the |
| 401 | job should be run. |
| 402 | |
| 403 | Jobs in Zuul support inheritance. Any job may specify a single parent |
| 404 | job, and any attributes not set on the child job are collected from |
| 405 | the parent job. In this way, a configuration structure may be built |
| 406 | starting with very basic jobs which describe characteristics that all |
| 407 | jobs on the system should have, progressing through stages of |
| 408 | specialization before arriving at a particular job. A job may inherit |
| 409 | from any other job in any project (however, if the other job is marked |
| 410 | as `final`, some attributes may not be overidden). |
| 411 | |
| 412 | Jobs also support a concept called variance. The first time a job |
| 413 | definition appears is called the reference definition of the job. |
| 414 | Subsequent job definitions with the same name are called variants. |
| 415 | These may have different selection criteria which indicate to Zuul |
| 416 | that, for instance, the job should behave differently on a different |
| 417 | git branch. Unlike inheritance, all job variants must be defined in |
| 418 | the same project. |
| 419 | |
| 420 | When Zuul decides to run a job, it performs a process known as |
| 421 | freezing the job. Because any number of job variants may be |
| 422 | applicable, Zuul collects all of the matching variants and applies |
| 423 | them in the order they appeared in the configuration. The resulting |
| 424 | frozen job is built from attributes gathered from all of the |
| 425 | matching variants. In this way, exactly what is run is dependent on |
| 426 | the pipeline, project, branch, and content of the item. |
| 427 | |
| 428 | In addition to the job's main playbook, each job may specify one or |
| 429 | more pre- and post-playbooks. These are run, in order, before and |
| 430 | after (respectively) the main playbook. They may be used to set up |
| 431 | and tear down resources needed by the main playbook. When combined |
| 432 | with inheritance, they provide powerful tools for job construction. A |
| 433 | job only has a single main playbook, and when inheriting from a |
| 434 | parent, the child's main playbook overrides (or replaces) the |
| 435 | parent's. However, the pre- and post-playbooks are appended and |
| 436 | prepended in a nesting fashion. So if a parent job and child job both |
| 437 | specified pre and post playbooks, the sequence of playbooks run would |
| 438 | be: |
| 439 | |
| 440 | * parent pre-run playbook |
| 441 | * child pre-run playbook |
| 442 | * child playbook |
| 443 | * child post-run playbook |
| 444 | * parent post-run playbook |
| 445 | |
| 446 | Further inheritance would nest even deeper. |
| 447 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 448 | Here is an example of two job definitions: |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 449 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 450 | .. code-block:: yaml |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 451 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 452 | - job: |
| 453 | name: base |
| 454 | pre-run: copy-git-repos |
| 455 | post-run: copy-logs |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 456 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 457 | - job: |
| 458 | name: run-tests |
| 459 | parent: base |
| 460 | nodes: |
| 461 | - name: test-node |
| 462 | image: fedora |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 463 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 464 | .. attr:: job |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 465 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 466 | The following attributes are available on a job; all are optional |
| 467 | unless otherwise specified: |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 468 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 469 | .. attr:: name |
| 470 | :required: |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 471 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 472 | The name of the job. By default, Zuul looks for a playbook with |
| 473 | this name to use as the main playbook for the job. This name is |
| 474 | also referenced later in a project pipeline configuration. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 475 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 476 | .. attr:: parent |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 477 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 478 | Specifie s a job to inherit from. The parent job can be defined |
| 479 | in this or a ny other project. Any attributes not specified on |
| 480 | a job will be collected from its parent. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 481 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 482 | .. attr:: description |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 483 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 484 | A textual description of the job. Not currently used directly |
| 485 | by Zuul, but it is used by the zuul-sphinx extension to Sphinx |
| 486 | to auto-document Zuul jobs (in which case it is interpreted as |
| 487 | ReStructuredText. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 488 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 489 | .. attr:: success-message |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 490 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 491 | Normally when a job succeeds, the string "SUCCESS" is reported |
| 492 | as the result for the job. If set, this option may be used to |
| 493 | supply a different string. Default: "SUCCESS". |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 494 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 495 | .. attr:: failure-message |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 496 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 497 | Normally when a job fails, the string "FAILURE" is reported as |
| 498 | the result for the job. If set, this option may be used to |
| 499 | supply a different string. Default: "FAILURE". |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 500 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 501 | .. attr:: success-url |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 502 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 503 | When a job succeeds, this URL is reported along with the result. |
| 504 | If this value is not supplied, Zuul uses the content of the job |
| 505 | :ref:`return value <return_values>` **zuul.log_url**. This is |
| 506 | recommended as it allows the code which stores the URL to the |
| 507 | job artifacts to report exactly where they were stored. To |
| 508 | override this value, or if it is not set, supply an absolute URL |
| 509 | in this field. If a relative URL is supplied in this field, and |
| 510 | **zuul.log_url** is set, then the two will be combined to |
| 511 | produce the URL used for the report. This can be used to |
| 512 | specify that certain jobs should "deep link" into the stored job |
| 513 | artifacts. Default: none. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 514 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 515 | .. attr:: failure-url |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 516 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 517 | When a job fails, this URL is reported along with the result. |
| 518 | Otherwise behaves the same as **success-url**. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 519 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 520 | .. attr:: hold-following-changes |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 521 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 522 | In a dependent pipeline, this option may be used to indicate |
| 523 | that no jobs should start on any items which depend on the |
| 524 | current item until this job has completed successfully. This |
| 525 | may be used to conserve build resources, at the expense of |
| 526 | inhibiting the parallelization which speeds the processing of |
| 527 | items in a dependent pipeline. A boolean value, default: false. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 528 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 529 | .. attr:: voting |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 530 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 531 | Indicates whether the result of this job should be used in |
| 532 | determining the overall result of the item. A boolean value, |
| 533 | default: true. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 534 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 535 | .. attr:: semaphore |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 536 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 537 | The name of a :ref:`semaphore` which should be acquired and |
| 538 | released when the job begins and ends. If the semaphore is at |
| 539 | maximum capacity, then Zuul will wait until it can be acquired |
| 540 | before starting the job. Default: none. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 541 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 542 | .. attr:: tags |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 543 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 544 | Metadata about this job. Tags are units of information attached |
| 545 | to the job; they do not affect Zuul's behavior, but they can be |
| 546 | used within the job to characterize the job. For example, a job |
| 547 | which tests a certain subsystem could be tagged with the name of |
| 548 | that subsystem, and if the job's results are reported into a |
| 549 | database, then the results of all jobs affecting that subsystem |
| 550 | could be queried. This attribute is specified as a list of |
| 551 | strings, and when inheriting jobs or applying variants, tags |
| 552 | accumulate in a set, so the result is always a set of all the |
| 553 | tags from all the jobs and variants used in constructing the |
| 554 | frozen job, with no duplication. Default: none. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 555 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 556 | .. attr:: branches |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 557 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 558 | A regular expression (or list of regular expressions) which |
| 559 | describe on what branches a job should run (or in the case of |
| 560 | variants: to alter the behavior of a job for a certain branch). |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 561 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 562 | If there is no job definition for a given job which matches the |
| 563 | branch of an item, then that job is not run for the item. |
| 564 | Otherwise, all of the job variants which match that branch (and |
| 565 | any other selection criteria) are used when freezing the job. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 566 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 567 | This example illustrates a job called *run-tests* which uses a |
| 568 | nodeset based on the current release of an operating system to |
| 569 | perform its tests, except when testing changes to the stable/2.0 |
| 570 | branch, in which case it uses an older release: |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 571 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 572 | .. code-block:: yaml |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 573 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 574 | - job: |
| 575 | name: run-tests |
| 576 | nodes: current-release |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 577 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 578 | - job: |
| 579 | name: run-tests |
| 580 | branch: stable/2.0 |
| 581 | nodes: old-release |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 582 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 583 | In some cases, Zuul uses an implied value for the branch specifier |
| 584 | if none is supplied: |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 585 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 586 | * For a job definition in a *config-project*, no implied branch |
| 587 | specifier is used. If no branch specifier appears, the job |
| 588 | applies to all branches. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 589 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 590 | * In the case of an *untrusted-project*, no implied branch specifier |
| 591 | is applied to the reference definition of a job. That is to say, |
| 592 | that if the first appearance of the job definition appears without |
| 593 | a branch specifier, then it will apply to all branches. Note that |
| 594 | when collecting its configuration, Zuul reads the `master` branch |
| 595 | of a given project first, then other branches in alphabetical |
| 596 | order. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 597 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 598 | * Any further job variants other than the reference definition in an |
| 599 | *untrusted-project* will, if they do not have a branch specifier, |
| 600 | will have an implied branch specifier for the current branch |
| 601 | applied. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 602 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 603 | This allows for the very simple and expected workflow where if a |
| 604 | project defines a job on the master branch with no branch specifier, |
| 605 | and then creates a new branch based on master, any changes to that |
| 606 | job definition within the new branch only affect that branch. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 607 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 608 | .. attr:: files |
Tobias Henkel | 2aade26 | 2017-07-12 16:09:06 +0200 | [diff] [blame] | 609 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 610 | This attribute indicates that the job should only run on changes |
| 611 | where the specified files are modified. This is a regular |
| 612 | expression or list of regular expressions. Default: none. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 613 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 614 | .. attr:: irrelevant-files |
James E. Blair | 74a82cf | 2017-07-12 17:23:08 -0700 | [diff] [blame] | 615 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 616 | This is a negative complement of `files`. It indicates that the |
| 617 | job should run unless *all* of the files changed match this |
| 618 | list. In other words, if the regular expression `docs/.*` is |
| 619 | supplied, then this job will not run if the only files changed |
| 620 | are in the docs directory. A regular expression or list of |
| 621 | regular expressions. Default: none. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 622 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 623 | .. attr:: auth |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 624 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 625 | Authentication information to be made available to the job. |
| 626 | This is a dictionary with two potential keys: |
James E. Blair | bb94dfa | 2017-07-11 07:45:19 -0700 | [diff] [blame] | 627 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 628 | .. attr:: inherit |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 629 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 630 | A boolean indicating that the authentication information |
| 631 | referenced by this job should be able to be inherited by |
| 632 | child jobs. Normally when a job inherits from another job, |
| 633 | the auth section is not included. This permits jobs to |
| 634 | inherit the same basic structure and playbook, but ensures |
| 635 | that secret information is unable to be exposed by a child |
| 636 | job which may alter the job's behavior. If it is safe for |
| 637 | the contents of the authentication section to be used by |
| 638 | child jobs, set this to ``true``. Default: ``false``. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 639 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 640 | .. attr:: secrets |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 641 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 642 | A list of secrets which may be used by the job. A |
| 643 | :ref:`secret` is a named collection of private information |
| 644 | defined separately in the configuration. The secrets that |
| 645 | appear here must be defined in the same project as this job |
| 646 | definition. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 647 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 648 | In the future, other types of authentication information may |
| 649 | be added. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 650 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 651 | .. attr:: nodes |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 652 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 653 | A list of nodes which should be supplied to the job. This |
| 654 | parameter may be supplied either as a string, in which case it |
| 655 | references a :ref:`nodeset` definition which appears elsewhere |
| 656 | in the configuration, or a list, in which case it is interpreted |
| 657 | in the same way as a Nodeset definition (in essence, it is an |
| 658 | anonymous Node definition unique to this job). See the |
| 659 | :ref:`nodeset` reference for the syntax to use in that case. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 660 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 661 | If a job has an empty or no node definition, it will still run |
| 662 | and may be able to perform actions on the Zuul executor. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 663 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 664 | .. attr:: override-branch |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 665 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 666 | When Zuul runs jobs for a proposed change, it normally checks |
| 667 | out the branch associated with that change on every project |
| 668 | present in the job. If jobs are running on a ref (such as a |
| 669 | branch tip or tag), then that ref is normally checked out. This |
| 670 | attribute is used to override that behavior and indicate that |
| 671 | this job should, regardless of the branch for the queue item, |
| 672 | use the indicated branch instead. This can be used, for |
| 673 | example, to run a previous version of the software (from a |
| 674 | stable maintenance branch) under test even if the change being |
| 675 | tested applies to a different branch (this is only likely to be |
| 676 | useful if there is some cross-branch interaction with some |
| 677 | component of the system being tested). See also the |
| 678 | project-specific **override-branch** attribute under |
| 679 | **required-projects** to apply this behavior to a subset of a |
| 680 | job's projects. |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 681 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 682 | .. attr:: timeout |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 683 | |
James E. Blair | 32c5248 | 2017-07-29 07:49:03 -0700 | [diff] [blame^] | 684 | The time in minutes that the job should be allowed to run before |
| 685 | it is automatically aborted and failure is reported. If no |
| 686 | timeout is supplied, the job may run indefinitely. Supplying a |
| 687 | timeout is highly recommended. |
| 688 | |
| 689 | .. attr:: attempts |
| 690 | |
| 691 | When Zuul encounters an error running a job's pre-run playbook, |
| 692 | Zuul will stop and restart the job. Errors during the main or |
| 693 | post-run -playbook phase of a job are not affected by this |
| 694 | parameter (they are reported immediately). This parameter |
| 695 | controls the number of attempts to make before an error is |
| 696 | reported. Default: 3. |
| 697 | |
| 698 | .. attr:: pre-run |
| 699 | |
| 700 | The name of a playbook or list of playbooks without file |
| 701 | extension to run before the main body of a job. The full path |
| 702 | to the playbook in the repo where the job is defined is |
| 703 | expected. |
| 704 | |
| 705 | When a job inherits from a parent, the child's pre-run playbooks |
| 706 | are run after the parent's. See :ref:`job` for more |
| 707 | information. |
| 708 | |
| 709 | .. attr:: post-run |
| 710 | |
| 711 | The name of a playbook or list of playbooks without file |
| 712 | extension to run after the main body of a job. The full path to |
| 713 | the playbook in the repo where the job is defined is expected. |
| 714 | |
| 715 | When a job inherits from a parent, the child's post-run |
| 716 | playbooks are run before the parent's. See :ref:`job` for more |
| 717 | information. |
| 718 | |
| 719 | .. attr:: run |
| 720 | |
| 721 | The name of the main playbook for this job. This parameter is |
| 722 | not normally necessary, as it defaults to a playbook with the |
| 723 | same name as the job inside of the `playbooks/` directory (e.g., |
| 724 | the `foo` job would default to `playbooks/foo`. However, if a |
| 725 | playbook with a different name is needed, it can be specified |
| 726 | here. The file extension is not required, but the full path |
| 727 | within the repo is. When a child inherits from a parent, a |
| 728 | playbook with the name of the child job is implicitly searched |
| 729 | first, before falling back on the playbook used by the parent |
| 730 | job (unless the child job specifies a ``run`` attribute, in |
| 731 | which case that value is used). Example: |
| 732 | |
| 733 | .. code-block:: yaml |
| 734 | |
| 735 | run: playbooks/<name of the job> |
| 736 | |
| 737 | .. attr:: roles |
| 738 | |
| 739 | A list of Ansible roles to prepare for the job. Because a job |
| 740 | runs an Ansible playbook, any roles which are used by the job |
| 741 | must be prepared and installed by Zuul before the job begins. |
| 742 | This value is a list of dictionaries, each of which indicates |
| 743 | one of two types of roles: a Galaxy role, which is simply a role |
| 744 | that is installed from Ansible Galaxy, or a Zuul role, which is |
| 745 | a role provided by a project managed by Zuul. Zuul roles are |
| 746 | able to benefit from speculative merging and cross-project |
| 747 | dependencies when used by playbooks in untrusted projects. |
| 748 | Roles are added to the Ansible role path in the order they |
| 749 | appear on the job -- roles earlier in the list will take |
| 750 | precedence over those which follow. |
| 751 | |
| 752 | In the case of job inheritance or variance, the roles used for |
| 753 | each of the playbooks run by the job will be only those which |
| 754 | were defined along with that playbook. If a child job inherits |
| 755 | from a parent which defines a pre and post playbook, then the |
| 756 | pre and post playbooks it inherits from the parent job will run |
| 757 | only with the roles that were defined on the parent. If the |
| 758 | child adds its own pre and post playbooks, then any roles added |
| 759 | by the child will be available to the child's playbooks. This |
| 760 | is so that a job which inherits from a parent does not |
| 761 | inadvertantly alter the behavior of the parent's playbooks by |
| 762 | the addition of conflicting roles. Roles added by a child will |
| 763 | appear before those it inherits from its parent. |
| 764 | |
| 765 | A project which supplies a role may be structured in one of two |
| 766 | configurations: a bare role (in which the role exists at the |
| 767 | root of the project), or a contained role (in which the role |
| 768 | exists within the `roles/` directory of the project, perhaps |
| 769 | along with other roles). In the case of a contained role, the |
| 770 | `roles/` directory of the project is added to the role search |
| 771 | path. In the case of a bare role, the project itself is added |
| 772 | to the role search path. In case the name of the project is not |
| 773 | the name under which the role should be installed (and therefore |
| 774 | referenced from Ansible), the `name` attribute may be used to |
| 775 | specify an alternate. |
| 776 | |
| 777 | A job automatically has the project in which it is defined added |
| 778 | to the roles path if that project appears to contain a role or |
| 779 | `roles/` directory. By default, the project is added to the |
| 780 | path under its own name, however, that may be changed by |
| 781 | explicitly listing the project in the roles list in the usual |
| 782 | way. |
| 783 | |
| 784 | .. note:: Galaxy roles are not yet implemented. |
| 785 | |
| 786 | .. attr:: galaxy |
| 787 | |
| 788 | The name of the role in Ansible Galaxy. If this attribute is |
| 789 | supplied, Zuul will search Ansible Galaxy for a role by this |
| 790 | name and install it. Mutually exclusive with ``zuul``; |
| 791 | either ``galaxy`` or ``zuul`` must be supplied. |
| 792 | |
| 793 | .. attr:: zuul |
| 794 | |
| 795 | The name of a Zuul project which supplies the role. Mutually |
| 796 | exclusive with ``galaxy``; either ``galaxy`` or ``zuul`` must |
| 797 | be supplied. |
| 798 | |
| 799 | .. attr:: name |
| 800 | |
| 801 | The installation name of the role. In the case of a bare |
| 802 | role, the role will be made available under this name. |
| 803 | Ignored in the case of a contained role. |
| 804 | |
| 805 | .. attr:: required-projects |
| 806 | |
| 807 | A list of other projects which are used by this job. Any Zuul |
| 808 | projects specified here will also be checked out by Zuul into |
| 809 | the working directory for the job. Speculative merging and |
| 810 | cross-repo dependencies will be honored. |
| 811 | |
| 812 | The format for this attribute is either a list of strings or |
| 813 | dictionaries. Strings are interpreted as project names, |
| 814 | dictionaries, if used, may have the following attributes: |
| 815 | |
| 816 | .. attr:: name |
| 817 | :required: |
| 818 | |
| 819 | The name of the required project. |
| 820 | |
| 821 | .. attr:: override-branch |
| 822 | |
| 823 | When Zuul runs jobs for a proposed change, it normally checks |
| 824 | out the branch associated with that change on every project |
| 825 | present in the job. If jobs are running on a ref (such as a |
| 826 | branch tip or tag), then that ref is normally checked out. |
| 827 | This attribute is used to override that behavior and indicate |
| 828 | that this job should, regardless of the branch for the queue |
| 829 | item, use the indicated branch instead, for only this |
| 830 | project. See also the **override-branch** attribute of jobs |
| 831 | to apply the same behavior to all projects in a job. |
| 832 | |
| 833 | .. attr:: vars |
| 834 | |
| 835 | A dictionary of variables to supply to Ansible. When inheriting |
| 836 | from a job (or creating a variant of a job) vars are merged with |
| 837 | previous definitions. This means a variable definition with the |
| 838 | same name will override a previously defined variable, but new |
| 839 | variable names will be added to the set of defined variables. |
| 840 | |
| 841 | .. attr:: dependencies |
| 842 | |
| 843 | A list of other jobs upon which this job depends. Zuul will not |
| 844 | start executing this job until all of its dependencies have |
| 845 | completed successfully, and if one or more of them fail, this |
| 846 | job will not be run. |
| 847 | |
| 848 | .. attr:: allowed-projects |
| 849 | |
| 850 | A list of Zuul projects which may use this job. By default, a |
| 851 | job may be used by any other project known to Zuul, however, |
| 852 | some jobs use resources or perform actions which are not |
| 853 | appropriate for other projects. In these cases, a list of |
| 854 | projects which are allowed to use this job may be supplied. If |
| 855 | this list is not empty, then it must be an exhaustive list of |
| 856 | all projects permitted to use the job. The current project |
| 857 | (where the job is defined) is not automatically included, so if |
| 858 | it should be able to run this job, then it must be explicitly |
| 859 | listed. Default: the empty list (all projects may use the job). |
James E. Blair | 1de8d40 | 2017-05-07 17:08:04 -0700 | [diff] [blame] | 860 | |
| 861 | |
| 862 | .. _project: |
| 863 | |
| 864 | Project |
| 865 | ~~~~~~~ |
| 866 | |
| 867 | A project corresponds to a source code repository with which Zuul is |
| 868 | configured to interact. The main responsibility of the `Project` |
| 869 | configuration item is to specify which jobs should run in which |
| 870 | pipelines for a given project. Within each `Project` definition, a |
| 871 | section for each `Pipeline` may appear. This project-pipeline |
| 872 | definition is what determines how a project participates in a |
| 873 | pipeline. |
| 874 | |
| 875 | Consider the following `Project` definition:: |
| 876 | |
| 877 | - project: |
| 878 | name: yoyodyne |
| 879 | check: |
| 880 | jobs: |
| 881 | - check-syntax |
| 882 | - unit-tests |
| 883 | gate: |
| 884 | queue: integrated |
| 885 | jobs: |
| 886 | - unit-tests |
| 887 | - integration-tests |
| 888 | |
| 889 | The project has two project-pipeline stanzas, one for the `check` |
| 890 | pipeline, and one for `gate`. Each specifies which jobs shuld run |
| 891 | when a change for that project enteres the respective pipeline -- when |
| 892 | a change enters `check`, the `check-syntax` and `unit-test` jobs are |
| 893 | run. |
| 894 | |
| 895 | Pipelines which use the dependent pipeline manager (e.g., the `gate` |
| 896 | example shown earlier) maintain separate queues for groups of |
| 897 | projects. When Zuul serializes a set of changes which represent |
| 898 | future potential project states, it must know about all of the |
| 899 | projects within Zuul which may have an effect on the outcome of the |
| 900 | jobs it runs. If project *A* uses project *B* as a library, then Zuul |
| 901 | must be told about that relationship so that it knows to serialize |
| 902 | changes to A and B together, so that it does not merge a change to B |
| 903 | while it is testing a change to A. |
| 904 | |
| 905 | Zuul could simply assume that all projects are related, or even infer |
| 906 | relationships by which projects a job indicates it uses, however, in a |
| 907 | large system that would become unwieldy very quickly, and |
| 908 | unnecessarily delay changes to unrelated projects. To allow for |
| 909 | flexibility in the construction of groups of related projects, the |
| 910 | change queues used by dependent pipeline managers are specified |
| 911 | manually. To group two or more related projects into a shared queue |
| 912 | for a dependent pipeline, set the ``queue`` parameter to the same |
| 913 | value for those projects. |
| 914 | |
| 915 | The `gate` project-pipeline definition above specifies that this |
| 916 | project participates in the `integrated` shared queue for that |
| 917 | pipeline. |
| 918 | |
| 919 | In addition to a project-pipeline definition for one or more |
| 920 | `Pipelines`, the following attributes may appear in a Project: |
| 921 | |
| 922 | **name** (required) |
| 923 | The name of the project. If Zuul is configured with two or more |
| 924 | unique projects with the same name, the canonical hostname for the |
| 925 | project should be included (e.g., `git.example.com/foo`). |
| 926 | |
| 927 | **templates** |
| 928 | A list of :ref:`project-template` references; the project-pipeline |
| 929 | definitions of each Project Template will be applied to this |
| 930 | project. If more than one template includes jobs for a given |
| 931 | pipeline, they will be combined, as will any jobs specified in |
| 932 | project-pipeline definitions on the project itself. |
| 933 | |
| 934 | .. _project-template: |
| 935 | |
| 936 | Project Template |
| 937 | ~~~~~~~~~~~~~~~~ |
| 938 | |
| 939 | A Project Template defines one or more project-pipeline definitions |
| 940 | which can be re-used by multiple projects. |
| 941 | |
| 942 | A Project Template uses the same syntax as a :ref:`project` |
| 943 | definition, however, in the case of a template, the ``name`` attribute |
| 944 | does not refer to the name of a project, but rather names the template |
| 945 | so that it can be referenced in a `Project` definition. |
| 946 | |
| 947 | .. _secret: |
| 948 | |
| 949 | Secret |
| 950 | ~~~~~~ |
| 951 | |
| 952 | A Secret is a collection of private data for use by one or more jobs. |
| 953 | In order to maintain the security of the data, the values are usually |
| 954 | encrypted, however, data which are not sensitive may be provided |
| 955 | unencrypted as well for convenience. |
| 956 | |
| 957 | A Secret may only be used by jobs defined within the same project. To |
| 958 | use a secret, a :ref:`job` must specify the secret within its `auth` |
| 959 | section. To protect against jobs in other repositories declaring a |
| 960 | job with a secret as a parent and then exposing that secret, jobs |
| 961 | which inherit from a job with secrets will not inherit the secrets |
| 962 | themselves. To alter that behavior, see the `inherit` job attribute. |
| 963 | Further, jobs which do not permit children to inherit secrets (the |
| 964 | default) are also automatically marked `final`, meaning that their |
| 965 | execution related attributes may not be changed in a project-pipeline |
| 966 | stanza. This is to protect against a job with secrets defined in one |
| 967 | project being used by another project in a way which might expose the |
| 968 | secrets. If a job with secrets is unsafe to be used by other |
| 969 | projects, the `allowed-projects` job attribute can be used to restrict |
| 970 | the projects which can invoke that job. Finally, pipelines which are |
| 971 | used to execute proposed but unreviewed changes can set the |
| 972 | `allow-secrets` attribute to indicate that they should not supply |
| 973 | secrets at all in order to protect against someone proposing a change |
| 974 | which exposes a secret. |
| 975 | |
| 976 | The following attributes are required: |
| 977 | |
| 978 | **name** (required) |
| 979 | The name of the secret, used in a :ref:`Job` definition to request |
| 980 | the secret. |
| 981 | |
| 982 | **data** (required) |
| 983 | A dictionary which will be added to the Ansible variables available |
| 984 | to the job. The values can either be plain text strings, or |
| 985 | encrypted values. See :ref:`encryption` for more information. |
| 986 | |
| 987 | .. _nodeset: |
| 988 | |
| 989 | Nodeset |
| 990 | ~~~~~~~ |
| 991 | |
| 992 | A Nodeset is a named collection of nodes for use by a job. Jobs may |
| 993 | specify what nodes they require individually, however, by defining |
| 994 | groups of node types once and referring to them by name, job |
| 995 | configuration may be simplified. |
| 996 | |
| 997 | A Nodeset requires two attributes: |
| 998 | |
| 999 | **name** (required) |
| 1000 | The name of the Nodeset, to be referenced by a :ref:`job`. |
| 1001 | |
| 1002 | **nodes** (required) |
| 1003 | A list of node definitions, each of which has the following format: |
| 1004 | |
| 1005 | **name** (required) |
| 1006 | The name of the node. This will appear in the Ansible inventory |
| 1007 | for the job. |
| 1008 | |
| 1009 | **label** (required) |
| 1010 | The Nodepool label for the node. Zuul will request a node with |
| 1011 | this label. |
| 1012 | |
| 1013 | .. _semaphore: |
| 1014 | |
| 1015 | Semaphore |
| 1016 | ~~~~~~~~~ |
| 1017 | |
| 1018 | Semaphores can be used to restrict the number of certain jobs which |
| 1019 | are running at the same time. This may be useful for jobs which |
| 1020 | access shared or limited resources. A semaphore has a value which |
| 1021 | represents the maximum number of jobs which use that semaphore at the |
| 1022 | same time. |
| 1023 | |
| 1024 | Semaphores are never subject to dynamic reconfiguration. If the value |
| 1025 | of a semaphore is changed, it will take effect only when the change |
| 1026 | where it is updated is merged. An example follows:: |
| 1027 | |
| 1028 | - semaphore: |
| 1029 | name: semaphore-foo |
| 1030 | max: 5 |
| 1031 | - semaphore: |
| 1032 | name: semaphore-bar |
| 1033 | max: 3 |
| 1034 | |
| 1035 | The following attributes are available: |
| 1036 | |
| 1037 | **name** (required) |
| 1038 | The name of the semaphore, referenced by jobs. |
| 1039 | |
| 1040 | **max** |
| 1041 | The maximum number of running jobs which can use this semaphore. |
| 1042 | Defaults to 1. |