blob: e356d44b2281ea0f1a5888b0c7c42c734a1b6e88 [file] [log] [blame]
James E. Blair1de8d402017-05-07 17:08:04 -07001:title: Project Configuration
2
3.. _project-config:
4
5Project Configuration
6=====================
7
8The following sections describe the main part of Zuul's configuration.
9All of what follows is found within files inside of the repositories
10that Zuul manages.
11
12Security Contexts
13-----------------
14
15When a system administrator configures Zuul to operate on a project,
16they specify one of two security contexts for that project. A
17*config-project* is one which is primarily tasked with holding
18configuration information and job content for Zuul. Jobs which are
James E. Blairac3c7ae2017-07-31 09:01:08 -070019defined in a config-project are run with elevated privileges, and all
James E. Blair2bab6e72017-08-07 09:52:45 -070020Zuul configuration items are available for use. Base jobs (that is,
21jobs without a parent) may only be defined in config-projects. It is
22expected that changes to config-projects will undergo careful scrutiny
23before being merged.
James E. Blair1de8d402017-05-07 17:08:04 -070024
25An *untrusted-project* is a project whose primary focus is not to
26operate Zuul, but rather it is one of the projects being tested or
27deployed. The Zuul configuration language available to these projects
James E. Blairac3c7ae2017-07-31 09:01:08 -070028is somewhat restricted (as detailed in individual sections below), and
James E. Blair1de8d402017-05-07 17:08:04 -070029jobs defined in these projects run in a restricted execution
30environment since they may be operating on changes which have not yet
31undergone review.
32
33Configuration Loading
34---------------------
35
36When Zuul starts, it examines all of the git repositories which are
James E. Blairac3c7ae2017-07-31 09:01:08 -070037specified by the system administrator in :ref:`tenant-config` and
38searches for files in the root of each repository. Zuul looks first
39for a file named ``zuul.yaml`` or a directory named ``zuul.d``, and if
40they are not found, ``.zuul.yaml`` or ``.zuul.d`` (with a leading
41dot). In the case of an :term:`untrusted-project`, the configuration
42from every branch is included, however, in the case of a
43:term:`config-project`, only the ``master`` branch is examined.
James E. Blair1de8d402017-05-07 17:08:04 -070044
45When a change is proposed to one of these files in an
James E. Blairac3c7ae2017-07-31 09:01:08 -070046untrusted-project, the configuration proposed in the change is merged
47into the running configuration so that any changes to Zuul's
James E. Blair1de8d402017-05-07 17:08:04 -070048configuration are self-testing as part of that change. If there is a
49configuration error, no jobs will be run and the error will be
50reported by any applicable pipelines. In the case of a change to a
James E. Blairac3c7ae2017-07-31 09:01:08 -070051config-project, the new configuration is parsed and examined for
James E. Blair1de8d402017-05-07 17:08:04 -070052errors, but the new configuration is not used in testing the change.
James E. Blairac3c7ae2017-07-31 09:01:08 -070053This is because configuration in config-projects is able to access
James E. Blair1de8d402017-05-07 17:08:04 -070054elevated privileges and should always be reviewed before being merged.
55
56As soon as a change containing a Zuul configuration change merges to
57any Zuul-managed repository, the new configuration takes effect
58immediately.
59
60Configuration Items
61-------------------
62
James E. Blairac3c7ae2017-07-31 09:01:08 -070063The ``zuul.yaml`` and ``.zuul.yaml`` configuration files are
James E. Blair1de8d402017-05-07 17:08:04 -070064YAML-formatted and are structured as a series of items, each of which
65is described below.
66
James E. Blairac3c7ae2017-07-31 09:01:08 -070067In the case of a ``zuul.d`` directory, Zuul recurses the directory and
68extends the configuration using all the .yaml files in the sorted path
69order. For example, to keep job's variants in a separate file, it
70needs to be loaded after the main entries, for example using number
71prefixes in file's names::
Tristan Cacqueray4a015832017-07-11 05:18:14 +000072
73* zuul.d/pipelines.yaml
74* zuul.d/projects.yaml
75* zuul.d/01_jobs.yaml
76* zuul.d/02_jobs-variants.yaml
77
James E. Blair1de8d402017-05-07 17:08:04 -070078.. _pipeline:
79
80Pipeline
81~~~~~~~~
82
83A pipeline describes a workflow operation in Zuul. It associates jobs
84for a given project with triggering and reporting events.
85
86Its flexible configuration allows for characterizing any number of
87workflows, and by specifying each as a named configuration, makes it
88easy to apply similar workflow operations to projects or groups of
89projects.
90
91By way of example, one of the primary uses of Zuul is to perform
James E. Blairac3c7ae2017-07-31 09:01:08 -070092project gating. To do so, one can create a :term:`gate` pipeline
93which tells Zuul that when a certain event (such as approval by a code
James E. Blair1de8d402017-05-07 17:08:04 -070094reviewer) occurs, the corresponding change or pull request should be
95enqueued into the pipeline. When that happens, the jobs which have
James E. Blairac3c7ae2017-07-31 09:01:08 -070096been configured to run for that project in the gate pipeline are run,
97and when they complete, the pipeline reports the results to the user.
James E. Blair1de8d402017-05-07 17:08:04 -070098
James E. Blairac3c7ae2017-07-31 09:01:08 -070099Pipeline configuration items may only appear in :term:`config-projects
100<config-project>`.
James E. Blair1de8d402017-05-07 17:08:04 -0700101
102Generally, a Zuul administrator would define a small number of
103pipelines which represent the workflow processes used in their
104environment. Each project can then be added to the available
105pipelines as appropriate.
106
James E. Blairac3c7ae2017-07-31 09:01:08 -0700107Here is an example :term:`check` pipeline, which runs whenever a new
James E. Blair1de8d402017-05-07 17:08:04 -0700108patchset is created in Gerrit. If the associated jobs all report
James E. Blairac3c7ae2017-07-31 09:01:08 -0700109success, the pipeline reports back to Gerrit with ``Verified`` vote of
James E. Blair32c52482017-07-29 07:49:03 -0700110+1, or if at least one of them fails, a -1:
James E. Blair1de8d402017-05-07 17:08:04 -0700111
James E. Blair32c52482017-07-29 07:49:03 -0700112.. code-block:: yaml
113
114 - pipeline:
115 name: check
116 manager: independent
117 trigger:
118 my_gerrit:
119 - event: patchset-created
120 success:
121 my_gerrit:
122 Verified: 1
123 failure:
124 my_gerrit
125 Verified: -1
James E. Blair1de8d402017-05-07 17:08:04 -0700126
James E. Blaireff5a9d2017-06-20 00:00:37 -0700127.. TODO: See TODO for more annotated examples of common pipeline configurations.
James E. Blair1de8d402017-05-07 17:08:04 -0700128
James E. Blair94375912017-07-28 17:20:27 -0700129.. attr:: pipeline
James E. Blair7145c582017-07-26 13:30:39 -0700130
James E. Blair9fd98ab2017-07-26 14:15:26 -0700131 The attributes available on a pipeline are as follows (all are
132 optional unless otherwise specified):
James E. Blair1de8d402017-05-07 17:08:04 -0700133
James E. Blair94375912017-07-28 17:20:27 -0700134 .. attr:: name
James E. Blair9fd98ab2017-07-26 14:15:26 -0700135 :required:
James E. Blair1de8d402017-05-07 17:08:04 -0700136
James E. Blair9fd98ab2017-07-26 14:15:26 -0700137 This is used later in the project definition to indicate what jobs
138 should be run for events in the pipeline.
James E. Blair1de8d402017-05-07 17:08:04 -0700139
James E. Blair94375912017-07-28 17:20:27 -0700140 .. attr:: manager
James E. Blair9fd98ab2017-07-26 14:15:26 -0700141 :required:
James E. Blaireff5a9d2017-06-20 00:00:37 -0700142
James E. Blair9fd98ab2017-07-26 14:15:26 -0700143 There are currently two schemes for managing pipelines:
James E. Blair1de8d402017-05-07 17:08:04 -0700144
James E. Blair32c52482017-07-29 07:49:03 -0700145 .. value:: independent
James E. Blaireff5a9d2017-06-20 00:00:37 -0700146
James E. Blair9fd98ab2017-07-26 14:15:26 -0700147 Every event in this pipeline should be treated as independent
148 of other events in the pipeline. This is appropriate when
149 the order of events in the pipeline doesn't matter because
150 the results of the actions this pipeline performs can not
151 affect other events in the pipeline. For example, when a
152 change is first uploaded for review, you may want to run
153 tests on that change to provide early feedback to reviewers.
154 At the end of the tests, the change is not going to be
155 merged, so it is safe to run these tests in parallel without
156 regard to any other changes in the pipeline. They are
157 independent.
James E. Blair1de8d402017-05-07 17:08:04 -0700158
James E. Blair9fd98ab2017-07-26 14:15:26 -0700159 Another type of pipeline that is independent is a post-merge
160 pipeline. In that case, the changes have already merged, so
161 the results can not affect any other events in the pipeline.
James E. Blair1761e862017-07-25 16:15:47 -0700162
James E. Blair32c52482017-07-29 07:49:03 -0700163 .. value:: dependent
James E. Blair1761e862017-07-25 16:15:47 -0700164
James E. Blair9fd98ab2017-07-26 14:15:26 -0700165 The dependent pipeline manager is designed for gating. It
166 ensures that every change is tested exactly as it is going to
167 be merged into the repository. An ideal gating system would
168 test one change at a time, applied to the tip of the
169 repository, and only if that change passed tests would it be
170 merged. Then the next change in line would be tested the
171 same way. In order to achieve parallel testing of changes,
172 the dependent pipeline manager performs speculative execution
173 on changes. It orders changes based on their entry into the
174 pipeline. It begins testing all changes in parallel,
175 assuming that each change ahead in the pipeline will pass its
176 tests. If they all succeed, all the changes can be tested
177 and merged in parallel. If a change near the front of the
178 pipeline fails its tests, each change behind it ignores
179 whatever tests have been completed and are tested again
180 without the change in front. This way gate tests may run in
181 parallel but still be tested correctly, exactly as they will
182 appear in the repository when merged.
James E. Blair1761e862017-07-25 16:15:47 -0700183
James E. Blair9fd98ab2017-07-26 14:15:26 -0700184 For more detail on the theory and operation of Zuul's
185 dependent pipeline manager, see: :doc:`gating`.
James E. Blair1de8d402017-05-07 17:08:04 -0700186
James E. Blair8eb564a2017-08-10 09:21:41 -0700187 .. attr:: post-review
James E. Blair88d84242017-07-31 12:05:16 -0700188 :default: false
James E. Blairf17aa9c2017-07-05 13:21:23 -0700189
James E. Blair8eb564a2017-08-10 09:21:41 -0700190 This is a boolean which indicates that this pipeline executes
191 code that has been reviewed. Some jobs perform actions which
192 should not be permitted with unreviewed code. When this value
193 is ``false`` those jobs will not be permitted to run in the
194 pipeline. If a pipeline is designed only to be used after
195 changes are reviewed or merged, set this value to ``true`` to
196 permit such jobs.
James E. Blairf17aa9c2017-07-05 13:21:23 -0700197
James E. Blair8eb564a2017-08-10 09:21:41 -0700198 For more information, see :ref:`secret` and
199 :attr:`job.post-review`.
James E. Blair1de8d402017-05-07 17:08:04 -0700200
James E. Blair94375912017-07-28 17:20:27 -0700201 .. attr:: description
James E. Blair1de8d402017-05-07 17:08:04 -0700202
James E. Blair9fd98ab2017-07-26 14:15:26 -0700203 This field may be used to provide a textual description of the
204 pipeline. It may appear in the status page or in documentation.
James E. Blair1de8d402017-05-07 17:08:04 -0700205
James E. Blair94375912017-07-28 17:20:27 -0700206 .. attr:: success-message
James E. Blair88d84242017-07-31 12:05:16 -0700207 :default: Build successful.
James E. Blair1de8d402017-05-07 17:08:04 -0700208
James E. Blair9fd98ab2017-07-26 14:15:26 -0700209 The introductory text in reports when all the voting jobs are
James E. Blair88d84242017-07-31 12:05:16 -0700210 successful.
James E. Blair1de8d402017-05-07 17:08:04 -0700211
James E. Blair94375912017-07-28 17:20:27 -0700212 .. attr:: failure-message
James E. Blair88d84242017-07-31 12:05:16 -0700213 :default: Build failed.
James E. Blair1de8d402017-05-07 17:08:04 -0700214
James E. Blair9fd98ab2017-07-26 14:15:26 -0700215 The introductory text in reports when at least one voting job
James E. Blair88d84242017-07-31 12:05:16 -0700216 fails.
James E. Blair1de8d402017-05-07 17:08:04 -0700217
James E. Blair94375912017-07-28 17:20:27 -0700218 .. attr:: merge-failure-message
James E. Blair88d84242017-07-31 12:05:16 -0700219 :default: Merge failed.
James E. Blair1de8d402017-05-07 17:08:04 -0700220
James E. Blair9fd98ab2017-07-26 14:15:26 -0700221 The introductory text in the message reported when a change
222 fails to merge with the current state of the repository.
223 Defaults to "Merge failed."
James E. Blair1de8d402017-05-07 17:08:04 -0700224
James E. Blair94375912017-07-28 17:20:27 -0700225 .. attr:: footer-message
James E. Blair1de8d402017-05-07 17:08:04 -0700226
James E. Blair9fd98ab2017-07-26 14:15:26 -0700227 Supplies additional information after test results. Useful for
228 adding information about the CI system such as debugging and
229 contact details.
James E. Blair1de8d402017-05-07 17:08:04 -0700230
James E. Blair94375912017-07-28 17:20:27 -0700231 .. attr:: trigger
James E. Blair1de8d402017-05-07 17:08:04 -0700232
James E. Blair9fd98ab2017-07-26 14:15:26 -0700233 At least one trigger source must be supplied for each pipeline.
234 Triggers are not exclusive -- matching events may be placed in
235 multiple pipelines, and they will behave independently in each
236 of the pipelines they match.
James E. Blair1de8d402017-05-07 17:08:04 -0700237
James E. Blair9fd98ab2017-07-26 14:15:26 -0700238 Triggers are loaded from their connection name. The driver type
239 of the connection will dictate which options are available. See
240 :ref:`drivers`.
James E. Blair1de8d402017-05-07 17:08:04 -0700241
James E. Blair94375912017-07-28 17:20:27 -0700242 .. attr:: require
James E. Blair1de8d402017-05-07 17:08:04 -0700243
James E. Blairac3c7ae2017-07-31 09:01:08 -0700244 If this section is present, it establishes prerequisites for
James E. Blair9fd98ab2017-07-26 14:15:26 -0700245 any kind of item entering the Pipeline. Regardless of how the
246 item is to be enqueued (via any trigger or automatic dependency
247 resolution), the conditions specified here must be met or the
James E. Blaird134c6d2017-07-26 16:09:34 -0700248 item will not be enqueued. These requirements may vary
249 depending on the source of the item being enqueued.
James E. Blair1de8d402017-05-07 17:08:04 -0700250
James E. Blaird134c6d2017-07-26 16:09:34 -0700251 Requirements are loaded from their connection name. The driver
252 type of the connection will dictate which options are available.
253 See :ref:`drivers`.
James E. Blair1de8d402017-05-07 17:08:04 -0700254
James E. Blair94375912017-07-28 17:20:27 -0700255 .. attr:: reject
James E. Blair1de8d402017-05-07 17:08:04 -0700256
James E. Blairac3c7ae2017-07-31 09:01:08 -0700257 If this section is present, it establishes prerequisites that
James E. Blair9fd98ab2017-07-26 14:15:26 -0700258 can block an item from being enqueued. It can be considered a
James E. Blairac3c7ae2017-07-31 09:01:08 -0700259 negative version of :attr:`pipeline.require`.
James E. Blair1de8d402017-05-07 17:08:04 -0700260
James E. Blaird134c6d2017-07-26 16:09:34 -0700261 Requirements are loaded from their connection name. The driver
262 type of the connection will dictate which options are available.
263 See :ref:`drivers`.
James E. Blair9fd98ab2017-07-26 14:15:26 -0700264
James E. Blair94375912017-07-28 17:20:27 -0700265 .. attr:: dequeue-on-new-patchset
James E. Blair88d84242017-07-31 12:05:16 -0700266 :default: true
James E. Blair9fd98ab2017-07-26 14:15:26 -0700267
268 Normally, if a new patchset is uploaded to a change that is in a
269 pipeline, the existing entry in the pipeline will be removed
270 (with jobs canceled and any dependent changes that can no longer
271 merge as well. To suppress this behavior (and allow jobs to
James E. Blair88d84242017-07-31 12:05:16 -0700272 continue running), set this to ``false``.
James E. Blair9fd98ab2017-07-26 14:15:26 -0700273
James E. Blair94375912017-07-28 17:20:27 -0700274 .. attr:: ignore-dependencies
James E. Blair88d84242017-07-31 12:05:16 -0700275 :default: false
James E. Blair9fd98ab2017-07-26 14:15:26 -0700276
277 In any kind of pipeline (dependent or independent), Zuul will
278 attempt to enqueue all dependencies ahead of the current change
279 so that they are tested together (independent pipelines report
280 the results of each change regardless of the results of changes
281 ahead). To ignore dependencies completely in an independent
282 pipeline, set this to ``true``. This option is ignored by
James E. Blair88d84242017-07-31 12:05:16 -0700283 dependent pipelines.
James E. Blair9fd98ab2017-07-26 14:15:26 -0700284
James E. Blair94375912017-07-28 17:20:27 -0700285 .. attr:: precedence
James E. Blair88d84242017-07-31 12:05:16 -0700286 :default: normal
James E. Blair9fd98ab2017-07-26 14:15:26 -0700287
288 Indicates how the build scheduler should prioritize jobs for
289 different pipelines. Each pipeline may have one precedence,
290 jobs for pipelines with a higher precedence will be run before
291 ones with lower. The value should be one of ``high``,
292 ``normal``, or ``low``. Default: ``normal``.
293
James E. Blairac3c7ae2017-07-31 09:01:08 -0700294 .. _reporters:
295
296 The following options configure :term:`reporters <reporter>`.
297 Reporters are complementary to triggers; where a trigger is an
298 event on a connection which causes Zuul to enqueue an item, a
299 reporter is the action performed on a connection when an item is
300 dequeued after its jobs complete. The actual syntax for a reporter
301 is defined by the driver which implements it. See :ref:`drivers`
302 for more information.
James E. Blair9fd98ab2017-07-26 14:15:26 -0700303
James E. Blair94375912017-07-28 17:20:27 -0700304 .. attr:: success
James E. Blair9fd98ab2017-07-26 14:15:26 -0700305
306 Describes where Zuul should report to if all the jobs complete
307 successfully. This section is optional; if it is omitted, Zuul
308 will run jobs and do nothing on success -- it will not report at
James E. Blairac3c7ae2017-07-31 09:01:08 -0700309 all. If the section is present, the listed :term:`reporters
310 <reporter>` will be asked to report on the jobs. The reporters
311 are listed by their connection name. The options available
312 depend on the driver for the supplied connection.
James E. Blair9fd98ab2017-07-26 14:15:26 -0700313
James E. Blair94375912017-07-28 17:20:27 -0700314 .. attr:: failure
James E. Blair9fd98ab2017-07-26 14:15:26 -0700315
316 These reporters describe what Zuul should do if at least one job
317 fails.
318
James E. Blair94375912017-07-28 17:20:27 -0700319 .. attr:: merge-failure
James E. Blair9fd98ab2017-07-26 14:15:26 -0700320
321 These reporters describe what Zuul should do if it is unable to
322 merge in the patchset. If no merge-failure reporters are listed
323 then the ``failure`` reporters will be used to notify of
324 unsuccessful merges.
325
James E. Blair94375912017-07-28 17:20:27 -0700326 .. attr:: start
James E. Blair9fd98ab2017-07-26 14:15:26 -0700327
328 These reporters describe what Zuul should do when a change is
329 added to the pipeline. This can be used, for example, to reset
330 a previously reported result.
331
James E. Blair94375912017-07-28 17:20:27 -0700332 .. attr:: disabled
James E. Blair9fd98ab2017-07-26 14:15:26 -0700333
334 These reporters describe what Zuul should do when a pipeline is
335 disabled. See ``disable-after-consecutive-failures``.
336
337 The following options can be used to alter Zuul's behavior to
338 mitigate situations in which jobs are failing frequently (perhaps
339 due to a problem with an external dependency, or unusually high
340 non-deterministic test failures).
341
James E. Blair94375912017-07-28 17:20:27 -0700342 .. attr:: disable-after-consecutive-failures
James E. Blair9fd98ab2017-07-26 14:15:26 -0700343
James E. Blairac3c7ae2017-07-31 09:01:08 -0700344 If set, a pipeline can enter a *disabled* state if too many
James E. Blair9fd98ab2017-07-26 14:15:26 -0700345 changes in a row fail. When this value is exceeded the pipeline
James E. Blairac3c7ae2017-07-31 09:01:08 -0700346 will stop reporting to any of the **success**, **failure** or
347 **merge-failure** reporters and instead only report to the
348 **disabled** reporters. (No **start** reports are made when a
James E. Blair9fd98ab2017-07-26 14:15:26 -0700349 pipeline is disabled).
350
James E. Blair94375912017-07-28 17:20:27 -0700351 .. attr:: window
James E. Blair88d84242017-07-31 12:05:16 -0700352 :default: 20
James E. Blair9fd98ab2017-07-26 14:15:26 -0700353
354 Dependent pipeline managers only. Zuul can rate limit dependent
355 pipelines in a manner similar to TCP flow control. Jobs are
356 only started for items in the queue if they are within the
357 actionable window for the pipeline. The initial length of this
358 window is configurable with this value. The value given should
359 be a positive integer value. A value of ``0`` disables rate
James E. Blairac3c7ae2017-07-31 09:01:08 -0700360 limiting on the :value:`dependent pipeline manager
James E. Blair88d84242017-07-31 12:05:16 -0700361 <pipeline.manager.dependent>`.
James E. Blair9fd98ab2017-07-26 14:15:26 -0700362
James E. Blair94375912017-07-28 17:20:27 -0700363 .. attr:: window-floor
James E. Blair88d84242017-07-31 12:05:16 -0700364 :default: 3
James E. Blair9fd98ab2017-07-26 14:15:26 -0700365
366 Dependent pipeline managers only. This is the minimum value for
367 the window described above. Should be a positive non zero
James E. Blair88d84242017-07-31 12:05:16 -0700368 integer value.
James E. Blair9fd98ab2017-07-26 14:15:26 -0700369
James E. Blair94375912017-07-28 17:20:27 -0700370 .. attr:: window-increase-type
James E. Blair88d84242017-07-31 12:05:16 -0700371 :default: linear
James E. Blair9fd98ab2017-07-26 14:15:26 -0700372
373 Dependent pipeline managers only. This value describes how the
James E. Blairac3c7ae2017-07-31 09:01:08 -0700374 window should grow when changes are successfully merged by zuul.
375
376 .. value:: linear
377
378 Indicates that **window-increase-factor** should be added to
James E. Blair88d84242017-07-31 12:05:16 -0700379 the previous window value.
James E. Blairac3c7ae2017-07-31 09:01:08 -0700380
381 .. value:: exponential
382
383 Indicates that **window-increase-factor** should be
384 multiplied against the previous window value and the result
385 will become the window size.
James E. Blair9fd98ab2017-07-26 14:15:26 -0700386
James E. Blair94375912017-07-28 17:20:27 -0700387 .. attr:: window-increase-factor
James E. Blair88d84242017-07-31 12:05:16 -0700388 :default: 1
James E. Blair9fd98ab2017-07-26 14:15:26 -0700389
390 Dependent pipeline managers only. The value to be added or
391 multiplied against the previous window value to determine the
James E. Blair88d84242017-07-31 12:05:16 -0700392 new window after successful change merges.
James E. Blair9fd98ab2017-07-26 14:15:26 -0700393
James E. Blair94375912017-07-28 17:20:27 -0700394 .. attr:: window-decrease-type
James E. Blair88d84242017-07-31 12:05:16 -0700395 :default: exponential
James E. Blair9fd98ab2017-07-26 14:15:26 -0700396
397 Dependent pipeline managers only. This value describes how the
398 window should shrink when changes are not able to be merged by
James E. Blairac3c7ae2017-07-31 09:01:08 -0700399 Zuul.
400
401 .. value:: linear
402
403 Indicates that **window-decrease-factor** should be
404 subtracted from the previous window value.
405
406 .. value:: exponential
407
408 Indicates that **window-decrease-factor** should be divided
409 against the previous window value and the result will become
James E. Blair88d84242017-07-31 12:05:16 -0700410 the window size.
James E. Blair9fd98ab2017-07-26 14:15:26 -0700411
James E. Blair94375912017-07-28 17:20:27 -0700412 .. attr:: window-decrease-factor
James E. Blair88d84242017-07-31 12:05:16 -0700413 :default: 2
James E. Blair9fd98ab2017-07-26 14:15:26 -0700414
James E. Blairac3c7ae2017-07-31 09:01:08 -0700415 :value:`Dependent pipeline managers
416 <pipeline.manager.dependent>` only. The value to be subtracted
417 or divided against the previous window value to determine the
James E. Blair88d84242017-07-31 12:05:16 -0700418 new window after unsuccessful change merges.
James E. Blair1de8d402017-05-07 17:08:04 -0700419
420
421.. _job:
422
423Job
424~~~
425
426A job is a unit of work performed by Zuul on an item enqueued into a
427pipeline. Items may run any number of jobs (which may depend on each
428other). Each job is an invocation of an Ansible playbook with a
429specific inventory of hosts. The actual tasks that are run by the job
430appear in the playbook for that job while the attributes that appear in the
431Zuul configuration specify information about when, where, and how the
432job should be run.
433
434Jobs in Zuul support inheritance. Any job may specify a single parent
435job, and any attributes not set on the child job are collected from
436the parent job. In this way, a configuration structure may be built
437starting with very basic jobs which describe characteristics that all
438jobs on the system should have, progressing through stages of
439specialization before arriving at a particular job. A job may inherit
440from any other job in any project (however, if the other job is marked
Tobias Henkel83167622017-06-30 19:45:03 +0200441as :attr:`job.final`, jobs may not inherit from it).
James E. Blair1de8d402017-05-07 17:08:04 -0700442
James E. Blair2bab6e72017-08-07 09:52:45 -0700443A job with no parent is called a *base job* and may only be defined in
444a :term:`config-project`. Every other job must have a parent, and so
445ultimately, all jobs must have an inheritance path which terminates at
446a base job. Each tenant has a default parent job which will be used
447if no explicit parent is specified.
448
James E. Blair1de8d402017-05-07 17:08:04 -0700449Jobs also support a concept called variance. The first time a job
450definition appears is called the reference definition of the job.
451Subsequent job definitions with the same name are called variants.
452These may have different selection criteria which indicate to Zuul
453that, for instance, the job should behave differently on a different
454git branch. Unlike inheritance, all job variants must be defined in
Tobias Henkel83167622017-06-30 19:45:03 +0200455the same project. Some attributes of jobs marked :attr:`job.final`
456may not be overidden
James E. Blair1de8d402017-05-07 17:08:04 -0700457
458When Zuul decides to run a job, it performs a process known as
459freezing the job. Because any number of job variants may be
460applicable, Zuul collects all of the matching variants and applies
461them in the order they appeared in the configuration. The resulting
462frozen job is built from attributes gathered from all of the
463matching variants. In this way, exactly what is run is dependent on
464the pipeline, project, branch, and content of the item.
465
466In addition to the job's main playbook, each job may specify one or
467more pre- and post-playbooks. These are run, in order, before and
468after (respectively) the main playbook. They may be used to set up
469and tear down resources needed by the main playbook. When combined
470with inheritance, they provide powerful tools for job construction. A
471job only has a single main playbook, and when inheriting from a
472parent, the child's main playbook overrides (or replaces) the
473parent's. However, the pre- and post-playbooks are appended and
474prepended in a nesting fashion. So if a parent job and child job both
475specified pre and post playbooks, the sequence of playbooks run would
476be:
477
478* parent pre-run playbook
479* child pre-run playbook
480* child playbook
481* child post-run playbook
482* parent post-run playbook
483
484Further inheritance would nest even deeper.
485
James E. Blair32c52482017-07-29 07:49:03 -0700486Here is an example of two job definitions:
James E. Blair1de8d402017-05-07 17:08:04 -0700487
James E. Blair32c52482017-07-29 07:49:03 -0700488.. code-block:: yaml
James E. Blair1de8d402017-05-07 17:08:04 -0700489
James E. Blair32c52482017-07-29 07:49:03 -0700490 - job:
491 name: base
492 pre-run: copy-git-repos
493 post-run: copy-logs
James E. Blair1de8d402017-05-07 17:08:04 -0700494
James E. Blair32c52482017-07-29 07:49:03 -0700495 - job:
496 name: run-tests
497 parent: base
498 nodes:
499 - name: test-node
David Shrewsburyc50cb572017-08-04 11:55:01 -0400500 label: fedora
James E. Blair1de8d402017-05-07 17:08:04 -0700501
James E. Blair32c52482017-07-29 07:49:03 -0700502.. attr:: job
James E. Blair1de8d402017-05-07 17:08:04 -0700503
James E. Blair32c52482017-07-29 07:49:03 -0700504 The following attributes are available on a job; all are optional
505 unless otherwise specified:
James E. Blair1de8d402017-05-07 17:08:04 -0700506
James E. Blair32c52482017-07-29 07:49:03 -0700507 .. attr:: name
508 :required:
James E. Blair1de8d402017-05-07 17:08:04 -0700509
James E. Blair32c52482017-07-29 07:49:03 -0700510 The name of the job. By default, Zuul looks for a playbook with
511 this name to use as the main playbook for the job. This name is
512 also referenced later in a project pipeline configuration.
James E. Blair1de8d402017-05-07 17:08:04 -0700513
James E. Blair2bab6e72017-08-07 09:52:45 -0700514 .. TODO: figure out how to link the parent default to tenant.default.parent
515
James E. Blair32c52482017-07-29 07:49:03 -0700516 .. attr:: parent
James E. Blair2bab6e72017-08-07 09:52:45 -0700517 :default: Tenant default-parent
James E. Blair1de8d402017-05-07 17:08:04 -0700518
James E. Blairac3c7ae2017-07-31 09:01:08 -0700519 Specifies a job to inherit from. The parent job can be defined
James E. Blair2bab6e72017-08-07 09:52:45 -0700520 in this or any other project. Any attributes not specified on a
521 job will be collected from its parent. If no value is supplied
522 here, the job specified by :attr:`tenant.default-parent` will be
523 used. If **parent** is set to ``null`` (which is only valid in
524 a :term:`config-project`), this is a :term:`base job`.
James E. Blair1de8d402017-05-07 17:08:04 -0700525
James E. Blair32c52482017-07-29 07:49:03 -0700526 .. attr:: description
James E. Blair1de8d402017-05-07 17:08:04 -0700527
James E. Blair32c52482017-07-29 07:49:03 -0700528 A textual description of the job. Not currently used directly
529 by Zuul, but it is used by the zuul-sphinx extension to Sphinx
530 to auto-document Zuul jobs (in which case it is interpreted as
531 ReStructuredText.
James E. Blair1de8d402017-05-07 17:08:04 -0700532
Tobias Henkel83167622017-06-30 19:45:03 +0200533 .. attr:: final
534 :default: false
535
536 To prevent other jobs from inheriting from this job, and also to
537 prevent changing execution-related attributes when this job is
538 specified in a project's pipeline, set this attribute to
539 ``true``.
540
James E. Blair32c52482017-07-29 07:49:03 -0700541 .. attr:: success-message
James E. Blair88d84242017-07-31 12:05:16 -0700542 :default: SUCCESS
James E. Blair1de8d402017-05-07 17:08:04 -0700543
James E. Blairac3c7ae2017-07-31 09:01:08 -0700544 Normally when a job succeeds, the string ``SUCCESS`` is reported
James E. Blair32c52482017-07-29 07:49:03 -0700545 as the result for the job. If set, this option may be used to
James E. Blair88d84242017-07-31 12:05:16 -0700546 supply a different string.
James E. Blair1de8d402017-05-07 17:08:04 -0700547
James E. Blair32c52482017-07-29 07:49:03 -0700548 .. attr:: failure-message
James E. Blair88d84242017-07-31 12:05:16 -0700549 :default: FAILURE
James E. Blair1de8d402017-05-07 17:08:04 -0700550
James E. Blairac3c7ae2017-07-31 09:01:08 -0700551 Normally when a job fails, the string ``FAILURE`` is reported as
James E. Blair32c52482017-07-29 07:49:03 -0700552 the result for the job. If set, this option may be used to
James E. Blair88d84242017-07-31 12:05:16 -0700553 supply a different string.
James E. Blair1de8d402017-05-07 17:08:04 -0700554
James E. Blair32c52482017-07-29 07:49:03 -0700555 .. attr:: success-url
James E. Blair1de8d402017-05-07 17:08:04 -0700556
James E. Blair32c52482017-07-29 07:49:03 -0700557 When a job succeeds, this URL is reported along with the result.
558 If this value is not supplied, Zuul uses the content of the job
559 :ref:`return value <return_values>` **zuul.log_url**. This is
560 recommended as it allows the code which stores the URL to the
561 job artifacts to report exactly where they were stored. To
562 override this value, or if it is not set, supply an absolute URL
563 in this field. If a relative URL is supplied in this field, and
564 **zuul.log_url** is set, then the two will be combined to
565 produce the URL used for the report. This can be used to
566 specify that certain jobs should "deep link" into the stored job
James E. Blair88d84242017-07-31 12:05:16 -0700567 artifacts.
James E. Blair1de8d402017-05-07 17:08:04 -0700568
James E. Blair32c52482017-07-29 07:49:03 -0700569 .. attr:: failure-url
James E. Blair1de8d402017-05-07 17:08:04 -0700570
James E. Blair32c52482017-07-29 07:49:03 -0700571 When a job fails, this URL is reported along with the result.
572 Otherwise behaves the same as **success-url**.
James E. Blair1de8d402017-05-07 17:08:04 -0700573
James E. Blair32c52482017-07-29 07:49:03 -0700574 .. attr:: hold-following-changes
James E. Blair88d84242017-07-31 12:05:16 -0700575 :default: false
James E. Blair1de8d402017-05-07 17:08:04 -0700576
James E. Blair32c52482017-07-29 07:49:03 -0700577 In a dependent pipeline, this option may be used to indicate
578 that no jobs should start on any items which depend on the
579 current item until this job has completed successfully. This
580 may be used to conserve build resources, at the expense of
581 inhibiting the parallelization which speeds the processing of
James E. Blair88d84242017-07-31 12:05:16 -0700582 items in a dependent pipeline.
James E. Blair1de8d402017-05-07 17:08:04 -0700583
James E. Blair32c52482017-07-29 07:49:03 -0700584 .. attr:: voting
James E. Blair88d84242017-07-31 12:05:16 -0700585 :default: true
James E. Blair1de8d402017-05-07 17:08:04 -0700586
James E. Blair32c52482017-07-29 07:49:03 -0700587 Indicates whether the result of this job should be used in
James E. Blair88d84242017-07-31 12:05:16 -0700588 determining the overall result of the item.
James E. Blair1de8d402017-05-07 17:08:04 -0700589
James E. Blair32c52482017-07-29 07:49:03 -0700590 .. attr:: semaphore
James E. Blair1de8d402017-05-07 17:08:04 -0700591
James E. Blair32c52482017-07-29 07:49:03 -0700592 The name of a :ref:`semaphore` which should be acquired and
593 released when the job begins and ends. If the semaphore is at
594 maximum capacity, then Zuul will wait until it can be acquired
James E. Blair88d84242017-07-31 12:05:16 -0700595 before starting the job.
James E. Blair1de8d402017-05-07 17:08:04 -0700596
James E. Blair32c52482017-07-29 07:49:03 -0700597 .. attr:: tags
James E. Blair1de8d402017-05-07 17:08:04 -0700598
James E. Blair32c52482017-07-29 07:49:03 -0700599 Metadata about this job. Tags are units of information attached
600 to the job; they do not affect Zuul's behavior, but they can be
601 used within the job to characterize the job. For example, a job
602 which tests a certain subsystem could be tagged with the name of
603 that subsystem, and if the job's results are reported into a
604 database, then the results of all jobs affecting that subsystem
605 could be queried. This attribute is specified as a list of
606 strings, and when inheriting jobs or applying variants, tags
607 accumulate in a set, so the result is always a set of all the
608 tags from all the jobs and variants used in constructing the
James E. Blair88d84242017-07-31 12:05:16 -0700609 frozen job, with no duplication.
James E. Blair1de8d402017-05-07 17:08:04 -0700610
James E. Blair32c52482017-07-29 07:49:03 -0700611 .. attr:: branches
James E. Blair1de8d402017-05-07 17:08:04 -0700612
James E. Blair32c52482017-07-29 07:49:03 -0700613 A regular expression (or list of regular expressions) which
614 describe on what branches a job should run (or in the case of
615 variants: to alter the behavior of a job for a certain branch).
James E. Blair1de8d402017-05-07 17:08:04 -0700616
James E. Blair32c52482017-07-29 07:49:03 -0700617 If there is no job definition for a given job which matches the
618 branch of an item, then that job is not run for the item.
619 Otherwise, all of the job variants which match that branch (and
620 any other selection criteria) are used when freezing the job.
James E. Blair1de8d402017-05-07 17:08:04 -0700621
James E. Blair32c52482017-07-29 07:49:03 -0700622 This example illustrates a job called *run-tests* which uses a
623 nodeset based on the current release of an operating system to
624 perform its tests, except when testing changes to the stable/2.0
625 branch, in which case it uses an older release:
James E. Blair1de8d402017-05-07 17:08:04 -0700626
James E. Blair32c52482017-07-29 07:49:03 -0700627 .. code-block:: yaml
James E. Blair1de8d402017-05-07 17:08:04 -0700628
James E. Blair32c52482017-07-29 07:49:03 -0700629 - job:
630 name: run-tests
631 nodes: current-release
James E. Blair1de8d402017-05-07 17:08:04 -0700632
James E. Blair32c52482017-07-29 07:49:03 -0700633 - job:
634 name: run-tests
635 branch: stable/2.0
636 nodes: old-release
James E. Blair1de8d402017-05-07 17:08:04 -0700637
James E. Blairac3c7ae2017-07-31 09:01:08 -0700638 In some cases, Zuul uses an implied value for the branch
639 specifier if none is supplied:
James E. Blair1de8d402017-05-07 17:08:04 -0700640
James E. Blairac3c7ae2017-07-31 09:01:08 -0700641 * For a job definition in a :term:`config-project`, no implied
642 branch specifier is used. If no branch specifier appears, the
643 job applies to all branches.
James E. Blair1de8d402017-05-07 17:08:04 -0700644
James E. Blairac3c7ae2017-07-31 09:01:08 -0700645 * In the case of an :term:`untrusted-project`, no implied branch
646 specifier is applied to the reference definition of a job.
647 That is to say, that if the first appearance of the job
648 definition appears without a branch specifier, then it will
649 apply to all branches. Note that when collecting its
650 configuration, Zuul reads the ``master`` branch of a given
651 project first, then other branches in alphabetical order.
James E. Blair1de8d402017-05-07 17:08:04 -0700652
James E. Blairac3c7ae2017-07-31 09:01:08 -0700653 * Any further job variants other than the reference definition
654 in an untrusted-project will, if they do not have a branch
655 specifier, will have an implied branch specifier for the
656 current branch applied.
James E. Blair1de8d402017-05-07 17:08:04 -0700657
James E. Blair32c52482017-07-29 07:49:03 -0700658 This allows for the very simple and expected workflow where if a
James E. Blairac3c7ae2017-07-31 09:01:08 -0700659 project defines a job on the ``master`` branch with no branch
660 specifier, and then creates a new branch based on ``master``,
661 any changes to that job definition within the new branch only
662 affect that branch.
James E. Blair1de8d402017-05-07 17:08:04 -0700663
James E. Blair32c52482017-07-29 07:49:03 -0700664 .. attr:: files
Tobias Henkel2aade262017-07-12 16:09:06 +0200665
James E. Blair32c52482017-07-29 07:49:03 -0700666 This attribute indicates that the job should only run on changes
667 where the specified files are modified. This is a regular
James E. Blair88d84242017-07-31 12:05:16 -0700668 expression or list of regular expressions.
James E. Blair1de8d402017-05-07 17:08:04 -0700669
James E. Blair32c52482017-07-29 07:49:03 -0700670 .. attr:: irrelevant-files
James E. Blair74a82cf2017-07-12 17:23:08 -0700671
James E. Blairac3c7ae2017-07-31 09:01:08 -0700672 This is a negative complement of **files**. It indicates that
673 the job should run unless *all* of the files changed match this
674 list. In other words, if the regular expression ``docs/.*`` is
James E. Blair32c52482017-07-29 07:49:03 -0700675 supplied, then this job will not run if the only files changed
676 are in the docs directory. A regular expression or list of
James E. Blair88d84242017-07-31 12:05:16 -0700677 regular expressions.
James E. Blair1de8d402017-05-07 17:08:04 -0700678
James E. Blaire19e88a2017-08-09 15:14:29 -0700679 .. attr:: secrets
James E. Blair1de8d402017-05-07 17:08:04 -0700680
James E. Blaire19e88a2017-08-09 15:14:29 -0700681 A list of secrets which may be used by the job. A
682 :ref:`secret` is a named collection of private information
683 defined separately in the configuration. The secrets that
684 appear here must be defined in the same project as this job
685 definition.
James E. Blair1de8d402017-05-07 17:08:04 -0700686
Monty Tayloraff8b402017-08-16 18:40:41 -0500687 Each item in the list may may be supplied either as a string,
688 in which case it references the name of a :ref:`secret` definition,
689 or as a dict. If an element in this list is given as a dict, it
690 must have the following fields.
691
692 .. attr:: name
693
694 The name to use for the Ansible variable into which the secret
695 content will be placed.
696
697 .. attr:: secret
698
699 The name to use to find the secret's definition in the configuration.
700
701 For example:
702
703 .. code-block:: yaml
704
705 - secret:
706 important-secret:
707 key: encrypted-secret-key-data
708
709 - job:
710 name: amazing-job:
711 secrets:
712 - name: ssh_key
713 secret: important-secret
714
715 will result in the following being passed as a variable to the playbooks
716 in ``amazing-job``:
717
718 .. code-block:: yaml
719
720 ssh_key:
721 key: descrypted-secret-key-data
722
James E. Blair32c52482017-07-29 07:49:03 -0700723 .. attr:: nodes
James E. Blair1de8d402017-05-07 17:08:04 -0700724
James E. Blair32c52482017-07-29 07:49:03 -0700725 A list of nodes which should be supplied to the job. This
726 parameter may be supplied either as a string, in which case it
727 references a :ref:`nodeset` definition which appears elsewhere
728 in the configuration, or a list, in which case it is interpreted
729 in the same way as a Nodeset definition (in essence, it is an
730 anonymous Node definition unique to this job). See the
731 :ref:`nodeset` reference for the syntax to use in that case.
James E. Blair1de8d402017-05-07 17:08:04 -0700732
James E. Blair32c52482017-07-29 07:49:03 -0700733 If a job has an empty or no node definition, it will still run
734 and may be able to perform actions on the Zuul executor.
James E. Blair1de8d402017-05-07 17:08:04 -0700735
James E. Blair32c52482017-07-29 07:49:03 -0700736 .. attr:: override-branch
James E. Blair1de8d402017-05-07 17:08:04 -0700737
James E. Blair32c52482017-07-29 07:49:03 -0700738 When Zuul runs jobs for a proposed change, it normally checks
739 out the branch associated with that change on every project
740 present in the job. If jobs are running on a ref (such as a
741 branch tip or tag), then that ref is normally checked out. This
742 attribute is used to override that behavior and indicate that
743 this job should, regardless of the branch for the queue item,
744 use the indicated branch instead. This can be used, for
745 example, to run a previous version of the software (from a
746 stable maintenance branch) under test even if the change being
747 tested applies to a different branch (this is only likely to be
748 useful if there is some cross-branch interaction with some
749 component of the system being tested). See also the
James E. Blairac3c7ae2017-07-31 09:01:08 -0700750 project-specific :attr:`job.required-projects.override-branch`
751 attribute to apply this behavior to a subset of a job's
752 projects.
James E. Blair1de8d402017-05-07 17:08:04 -0700753
James E. Blair32c52482017-07-29 07:49:03 -0700754 .. attr:: timeout
James E. Blair1de8d402017-05-07 17:08:04 -0700755
James E. Blair32c52482017-07-29 07:49:03 -0700756 The time in minutes that the job should be allowed to run before
757 it is automatically aborted and failure is reported. If no
758 timeout is supplied, the job may run indefinitely. Supplying a
759 timeout is highly recommended.
760
761 .. attr:: attempts
James E. Blair88d84242017-07-31 12:05:16 -0700762 :default: 3
James E. Blair32c52482017-07-29 07:49:03 -0700763
764 When Zuul encounters an error running a job's pre-run playbook,
765 Zuul will stop and restart the job. Errors during the main or
766 post-run -playbook phase of a job are not affected by this
767 parameter (they are reported immediately). This parameter
768 controls the number of attempts to make before an error is
James E. Blair88d84242017-07-31 12:05:16 -0700769 reported.
James E. Blair32c52482017-07-29 07:49:03 -0700770
771 .. attr:: pre-run
772
773 The name of a playbook or list of playbooks without file
774 extension to run before the main body of a job. The full path
775 to the playbook in the repo where the job is defined is
776 expected.
777
778 When a job inherits from a parent, the child's pre-run playbooks
779 are run after the parent's. See :ref:`job` for more
780 information.
781
782 .. attr:: post-run
783
784 The name of a playbook or list of playbooks without file
785 extension to run after the main body of a job. The full path to
786 the playbook in the repo where the job is defined is expected.
787
788 When a job inherits from a parent, the child's post-run
789 playbooks are run before the parent's. See :ref:`job` for more
790 information.
791
792 .. attr:: run
793
794 The name of the main playbook for this job. This parameter is
795 not normally necessary, as it defaults to a playbook with the
James E. Blairac3c7ae2017-07-31 09:01:08 -0700796 same name as the job inside of the ``playbooks/`` directory
797 (e.g., the ``foo`` job would default to ``playbooks/foo``.
798 However, if a playbook with a different name is needed, it can
799 be specified here. The file extension is not required, but the
800 full path within the repo is. When a child inherits from a
801 parent, a playbook with the name of the child job is implicitly
802 searched first, before falling back on the playbook used by the
803 parent job (unless the child job specifies a ``run`` attribute,
804 in which case that value is used). Example:
James E. Blair32c52482017-07-29 07:49:03 -0700805
806 .. code-block:: yaml
807
808 run: playbooks/<name of the job>
809
810 .. attr:: roles
811
812 A list of Ansible roles to prepare for the job. Because a job
813 runs an Ansible playbook, any roles which are used by the job
814 must be prepared and installed by Zuul before the job begins.
815 This value is a list of dictionaries, each of which indicates
816 one of two types of roles: a Galaxy role, which is simply a role
817 that is installed from Ansible Galaxy, or a Zuul role, which is
818 a role provided by a project managed by Zuul. Zuul roles are
819 able to benefit from speculative merging and cross-project
820 dependencies when used by playbooks in untrusted projects.
821 Roles are added to the Ansible role path in the order they
822 appear on the job -- roles earlier in the list will take
823 precedence over those which follow.
824
825 In the case of job inheritance or variance, the roles used for
826 each of the playbooks run by the job will be only those which
827 were defined along with that playbook. If a child job inherits
828 from a parent which defines a pre and post playbook, then the
829 pre and post playbooks it inherits from the parent job will run
830 only with the roles that were defined on the parent. If the
831 child adds its own pre and post playbooks, then any roles added
832 by the child will be available to the child's playbooks. This
833 is so that a job which inherits from a parent does not
James E. Blairac3c7ae2017-07-31 09:01:08 -0700834 inadvertently alter the behavior of the parent's playbooks by
James E. Blair32c52482017-07-29 07:49:03 -0700835 the addition of conflicting roles. Roles added by a child will
836 appear before those it inherits from its parent.
837
838 A project which supplies a role may be structured in one of two
839 configurations: a bare role (in which the role exists at the
840 root of the project), or a contained role (in which the role
James E. Blairac3c7ae2017-07-31 09:01:08 -0700841 exists within the ``roles/`` directory of the project, perhaps
James E. Blair32c52482017-07-29 07:49:03 -0700842 along with other roles). In the case of a contained role, the
James E. Blairac3c7ae2017-07-31 09:01:08 -0700843 ``roles/`` directory of the project is added to the role search
James E. Blair32c52482017-07-29 07:49:03 -0700844 path. In the case of a bare role, the project itself is added
845 to the role search path. In case the name of the project is not
846 the name under which the role should be installed (and therefore
James E. Blairac3c7ae2017-07-31 09:01:08 -0700847 referenced from Ansible), the ``name`` attribute may be used to
James E. Blair32c52482017-07-29 07:49:03 -0700848 specify an alternate.
849
850 A job automatically has the project in which it is defined added
851 to the roles path if that project appears to contain a role or
James E. Blairac3c7ae2017-07-31 09:01:08 -0700852 ``roles/`` directory. By default, the project is added to the
James E. Blair32c52482017-07-29 07:49:03 -0700853 path under its own name, however, that may be changed by
854 explicitly listing the project in the roles list in the usual
855 way.
856
857 .. note:: Galaxy roles are not yet implemented.
858
859 .. attr:: galaxy
860
861 The name of the role in Ansible Galaxy. If this attribute is
862 supplied, Zuul will search Ansible Galaxy for a role by this
863 name and install it. Mutually exclusive with ``zuul``;
864 either ``galaxy`` or ``zuul`` must be supplied.
865
866 .. attr:: zuul
867
868 The name of a Zuul project which supplies the role. Mutually
869 exclusive with ``galaxy``; either ``galaxy`` or ``zuul`` must
870 be supplied.
871
872 .. attr:: name
873
874 The installation name of the role. In the case of a bare
875 role, the role will be made available under this name.
876 Ignored in the case of a contained role.
877
878 .. attr:: required-projects
879
880 A list of other projects which are used by this job. Any Zuul
881 projects specified here will also be checked out by Zuul into
882 the working directory for the job. Speculative merging and
883 cross-repo dependencies will be honored.
884
885 The format for this attribute is either a list of strings or
886 dictionaries. Strings are interpreted as project names,
887 dictionaries, if used, may have the following attributes:
888
889 .. attr:: name
890 :required:
891
892 The name of the required project.
893
894 .. attr:: override-branch
895
896 When Zuul runs jobs for a proposed change, it normally checks
897 out the branch associated with that change on every project
898 present in the job. If jobs are running on a ref (such as a
899 branch tip or tag), then that ref is normally checked out.
900 This attribute is used to override that behavior and indicate
901 that this job should, regardless of the branch for the queue
902 item, use the indicated branch instead, for only this
James E. Blairac3c7ae2017-07-31 09:01:08 -0700903 project. See also the :attr:`job.override-branch` attribute
James E. Blair32c52482017-07-29 07:49:03 -0700904 to apply the same behavior to all projects in a job.
905
906 .. attr:: vars
907
908 A dictionary of variables to supply to Ansible. When inheriting
909 from a job (or creating a variant of a job) vars are merged with
910 previous definitions. This means a variable definition with the
911 same name will override a previously defined variable, but new
912 variable names will be added to the set of defined variables.
913
914 .. attr:: dependencies
915
916 A list of other jobs upon which this job depends. Zuul will not
917 start executing this job until all of its dependencies have
918 completed successfully, and if one or more of them fail, this
919 job will not be run.
920
921 .. attr:: allowed-projects
922
923 A list of Zuul projects which may use this job. By default, a
924 job may be used by any other project known to Zuul, however,
925 some jobs use resources or perform actions which are not
926 appropriate for other projects. In these cases, a list of
927 projects which are allowed to use this job may be supplied. If
928 this list is not empty, then it must be an exhaustive list of
929 all projects permitted to use the job. The current project
930 (where the job is defined) is not automatically included, so if
931 it should be able to run this job, then it must be explicitly
James E. Blair88d84242017-07-31 12:05:16 -0700932 listed. By default, all projects may use the job.
James E. Blair1de8d402017-05-07 17:08:04 -0700933
James E. Blair8eb564a2017-08-10 09:21:41 -0700934 .. attr:: post-review
935 :default: false
James E. Blair892cca62017-08-09 11:36:58 -0700936
James E. Blair8eb564a2017-08-10 09:21:41 -0700937 A boolean value which indicates whether this job may only be
938 used in pipelines where :attr:`pipeline.post-review` is
939 ``true``. This is automatically set to ``true`` if this job is
940 defined in a :term:`untrusted-project`. It may be explicitly
941 set to obtain the same behavior for jobs defined in
942 :term:`config projects <config-project>`. Once this is set to
943 ``true`` anywhere in the inheritance hierarchy for a job, it
944 will remain set for all child jobs and variants (it can not be
945 set to ``false``).
James E. Blair1de8d402017-05-07 17:08:04 -0700946
947.. _project:
948
949Project
950~~~~~~~
951
952A project corresponds to a source code repository with which Zuul is
James E. Blairac3c7ae2017-07-31 09:01:08 -0700953configured to interact. The main responsibility of the project
James E. Blair1de8d402017-05-07 17:08:04 -0700954configuration item is to specify which jobs should run in which
James E. Blairac3c7ae2017-07-31 09:01:08 -0700955pipelines for a given project. Within each project definition, a
956section for each :ref:`pipeline <pipeline>` may appear. This
957project-pipeline definition is what determines how a project
958participates in a pipeline.
James E. Blair1de8d402017-05-07 17:08:04 -0700959
James E. Blairac3c7ae2017-07-31 09:01:08 -0700960Consider the following project definition::
James E. Blair1de8d402017-05-07 17:08:04 -0700961
962 - project:
963 name: yoyodyne
964 check:
965 jobs:
966 - check-syntax
967 - unit-tests
968 gate:
969 queue: integrated
970 jobs:
971 - unit-tests
972 - integration-tests
973
James E. Blairac3c7ae2017-07-31 09:01:08 -0700974The project has two project-pipeline stanzas, one for the ``check``
975pipeline, and one for ``gate``. Each specifies which jobs should run
976when a change for that project enters the respective pipeline -- when
977a change enters ``check``, the ``check-syntax`` and ``unit-test`` jobs
978are run.
James E. Blair1de8d402017-05-07 17:08:04 -0700979
James E. Blairac3c7ae2017-07-31 09:01:08 -0700980Pipelines which use the dependent pipeline manager (e.g., the ``gate``
James E. Blair1de8d402017-05-07 17:08:04 -0700981example shown earlier) maintain separate queues for groups of
982projects. When Zuul serializes a set of changes which represent
983future potential project states, it must know about all of the
984projects within Zuul which may have an effect on the outcome of the
985jobs it runs. If project *A* uses project *B* as a library, then Zuul
986must be told about that relationship so that it knows to serialize
987changes to A and B together, so that it does not merge a change to B
988while it is testing a change to A.
989
990Zuul could simply assume that all projects are related, or even infer
991relationships by which projects a job indicates it uses, however, in a
992large system that would become unwieldy very quickly, and
993unnecessarily delay changes to unrelated projects. To allow for
994flexibility in the construction of groups of related projects, the
995change queues used by dependent pipeline managers are specified
996manually. To group two or more related projects into a shared queue
997for a dependent pipeline, set the ``queue`` parameter to the same
998value for those projects.
999
James E. Blairac3c7ae2017-07-31 09:01:08 -07001000The ``gate`` project-pipeline definition above specifies that this
1001project participates in the ``integrated`` shared queue for that
James E. Blair1de8d402017-05-07 17:08:04 -07001002pipeline.
1003
James E. Blair9d4384d2017-08-01 15:54:50 -07001004.. attr:: project
James E. Blair1de8d402017-05-07 17:08:04 -07001005
James E. Blair9d4384d2017-08-01 15:54:50 -07001006 In addition to a project-pipeline definition for one or more
1007 pipelines, the following attributes may appear in a project:
James E. Blair1de8d402017-05-07 17:08:04 -07001008
James E. Blair9d4384d2017-08-01 15:54:50 -07001009 .. attr:: name
1010 :required:
1011
1012 The name of the project. If Zuul is configured with two or more
1013 unique projects with the same name, the canonical hostname for
1014 the project should be included (e.g., `git.example.com/foo`).
1015
1016 .. attr:: templates
1017
1018 A list of :ref:`project-template` references; the
1019 project-pipeline definitions of each Project Template will be
1020 applied to this project. If more than one template includes
1021 jobs for a given pipeline, they will be combined, as will any
1022 jobs specified in project-pipeline definitions on the project
1023 itself.
1024
1025 .. attr:: merge-mode
1026 :default: merge-resolve
1027
1028 The merge mode which is used by Git for this project. Be sure
1029 this matches what the remote system which performs merges (i.e.,
1030 Gerrit or GitHub). Must be one of the following values:
1031
1032 .. value:: merge
1033
1034 Uses the default git merge strategy (recursive).
1035
1036 .. value:: merge-resolve
1037
1038 Uses the resolve git merge strategy. This is a very
1039 conservative merge strategy which most closely matches the
1040 behavior of Gerrit.
1041
1042 .. value:: cherry-pick
1043
1044 Cherry-picks each change onto the branch rather than
1045 performing any merges.
1046
1047 .. attr:: <pipeline>
1048
1049 Each pipeline that the project participates in should have an
1050 entry in the project. The value for this key should be a
1051 dictionary with the following format:
1052
1053 .. attr:: jobs
1054 :required:
1055
1056 A list of jobs that should be run when items for this project
1057 are enqueued into the pipeline. Each item of this list may
1058 be a string, in which case it is treated as a job name, or it
1059 may be a dictionary, in which case it is treated as a job
1060 variant local to this project and pipeline. In that case,
1061 the format of the dictionary is the same as the top level
1062 :attr:`job` definition. Any attributes set on the job here
1063 will override previous versions of the job.
1064
1065 .. attr:: queue
1066
1067 If this pipeline is a :value:`dependent
1068 <pipeline.manager.dependent>` pipeline, this specifies the
1069 name of the shared queue this project is in. Any projects
1070 which interact with each other in tests should be part of the
1071 same shared queue in order to ensure that they don't merge
1072 changes which break the others. This is a free-form string;
1073 just set the same value for each group of projects.
James E. Blair1de8d402017-05-07 17:08:04 -07001074
1075.. _project-template:
1076
1077Project Template
1078~~~~~~~~~~~~~~~~
1079
1080A Project Template defines one or more project-pipeline definitions
1081which can be re-used by multiple projects.
1082
1083A Project Template uses the same syntax as a :ref:`project`
James E. Blairaafabe92017-08-02 15:23:19 -07001084definition, however, in the case of a template, the
1085:attr:`project.name` attribute does not refer to the name of a
1086project, but rather names the template so that it can be referenced in
1087a `Project` definition.
James E. Blair1de8d402017-05-07 17:08:04 -07001088
1089.. _secret:
1090
1091Secret
1092~~~~~~
1093
1094A Secret is a collection of private data for use by one or more jobs.
1095In order to maintain the security of the data, the values are usually
1096encrypted, however, data which are not sensitive may be provided
1097unencrypted as well for convenience.
1098
1099A Secret may only be used by jobs defined within the same project. To
James E. Blaire19e88a2017-08-09 15:14:29 -07001100use a secret, a :ref:`job` must specify the secret in
1101:attr:`job.secrets`. Secrets are bound to the playbooks associated
1102with the specific job definition where they were declared. Additional
1103pre or post playbooks which appear in child jobs will not have access
1104to the secrets, nor will playbooks which override the main playbook
1105(if any) of the job which declared the secret. This protects against
1106jobs in other repositories declaring a job with a secret as a parent
1107and then exposing that secret.
James E. Blair892cca62017-08-09 11:36:58 -07001108
1109It is possible to use secrets for jobs defined in :term:`config
1110projects <config-project>` as well as :term:`untrusted projects
1111<untrusted-project>`, however their use differs slightly. Because
1112playbooks in a config project which use secrets run in the
1113:term:`trusted execution context` where proposed changes are not used
1114in executing jobs, it is safe for those secrets to be used in all
1115types of pipelines. However, because playbooks defined in an
1116untrusted project are run in the :term:`untrusted execution context`
1117where proposed changes are used in job execution, it is dangerous to
1118allow those secrets to be used in pipelines which are used to execute
James E. Blair8eb564a2017-08-10 09:21:41 -07001119proposed but unreviewed changes. By default, pipelines are considered
1120`pre-review` and will refuse to run jobs which have playbooks that use
1121secrets in the untrusted execution context to protect against someone
1122proposing a change which exposes a secret. To permit this (for
1123instance, in a pipeline which only runs after code review), the
1124:attr:`pipeline.post-review` attribute may be explicitly set to
1125``true``.
1126
1127In some cases, it may be desirable to prevent a job which is defined
1128in a config project from running in a pre-review pipeline (e.g., a job
1129used to publish an artifact). In these cases, the
1130:attr:`job.post-review` attribute may be explicitly set to ``true`` to
1131indicate the job should only run in post-review pipelines.
James E. Blair892cca62017-08-09 11:36:58 -07001132
1133If a job with secrets is unsafe to be used by other projects, the
1134`allowed-projects` job attribute can be used to restrict the projects
1135which can invoke that job.
James E. Blair1de8d402017-05-07 17:08:04 -07001136
James E. Blairaafabe92017-08-02 15:23:19 -07001137.. attr:: secret
James E. Blair1de8d402017-05-07 17:08:04 -07001138
James E. Blairaafabe92017-08-02 15:23:19 -07001139 The following attributes must appear on a secret:
James E. Blair1de8d402017-05-07 17:08:04 -07001140
James E. Blairaafabe92017-08-02 15:23:19 -07001141 .. attr:: name
1142 :required:
1143
1144 The name of the secret, used in a :ref:`Job` definition to
1145 request the secret.
1146
1147 .. attr:: data
1148 :required:
1149
1150 A dictionary which will be added to the Ansible variables
1151 available to the job. The values can either be plain text
1152 strings, or encrypted values. See :ref:`encryption` for more
1153 information.
James E. Blair1de8d402017-05-07 17:08:04 -07001154
1155.. _nodeset:
1156
1157Nodeset
1158~~~~~~~
1159
1160A Nodeset is a named collection of nodes for use by a job. Jobs may
1161specify what nodes they require individually, however, by defining
1162groups of node types once and referring to them by name, job
1163configuration may be simplified.
1164
Tobias Henkeldb686e22017-08-01 09:15:31 +02001165.. code-block:: yaml
James E. Blair1de8d402017-05-07 17:08:04 -07001166
Tobias Henkeldb686e22017-08-01 09:15:31 +02001167 - nodeset:
1168 name: nodeset1
1169 nodes:
1170 - name: controller
1171 label: controller-label
1172 - name: compute1
1173 label: compute-label
1174 - name: compute2
1175 label: compute-label
1176 groups:
1177 - name: ceph-osd
1178 nodes:
1179 - controller
1180 - name: ceph-monitor
1181 nodes:
1182 - controller
1183 - compute1
1184 - compute2
James E. Blair1de8d402017-05-07 17:08:04 -07001185
Tobias Henkeldb686e22017-08-01 09:15:31 +02001186.. attr:: nodeset
James E. Blair1de8d402017-05-07 17:08:04 -07001187
Tobias Henkeldb686e22017-08-01 09:15:31 +02001188 A Nodeset requires two attributes:
James E. Blair1de8d402017-05-07 17:08:04 -07001189
Tobias Henkeldb686e22017-08-01 09:15:31 +02001190 .. attr:: name
1191 :required:
1192
1193 The name of the Nodeset, to be referenced by a :ref:`job`.
1194
1195 .. attr:: nodes
1196 :required:
1197
1198 A list of node definitions, each of which has the following format:
1199
1200 .. attr:: name
1201 :required:
1202
1203 The name of the node. This will appear in the Ansible inventory
1204 for the job.
1205
1206 .. attr:: label
1207 :required:
1208
1209 The Nodepool label for the node. Zuul will request a node with
1210 this label.
1211
1212 .. attr:: groups
1213
1214 Additional groups can be defined which are accessible from the ansible
1215 playbooks.
1216
1217 .. attr:: name
1218 :required:
1219
1220 The name of the group to be referenced by an ansible playbook.
1221
1222 .. attr:: nodes
1223 :required:
1224
1225 The nodes that shall be part of the group. This is specified as a list
1226 of strings.
James E. Blair1de8d402017-05-07 17:08:04 -07001227
1228.. _semaphore:
1229
1230Semaphore
1231~~~~~~~~~
1232
1233Semaphores can be used to restrict the number of certain jobs which
1234are running at the same time. This may be useful for jobs which
1235access shared or limited resources. A semaphore has a value which
1236represents the maximum number of jobs which use that semaphore at the
1237same time.
1238
1239Semaphores are never subject to dynamic reconfiguration. If the value
1240of a semaphore is changed, it will take effect only when the change
Tobias Henkel76832982017-08-01 08:37:40 +02001241where it is updated is merged. An example follows:
James E. Blair1de8d402017-05-07 17:08:04 -07001242
Tobias Henkel76832982017-08-01 08:37:40 +02001243.. code-block:: yaml
James E. Blair1de8d402017-05-07 17:08:04 -07001244
Tobias Henkel76832982017-08-01 08:37:40 +02001245 - semaphore:
1246 name: semaphore-foo
1247 max: 5
1248 - semaphore:
1249 name: semaphore-bar
1250 max: 3
James E. Blair1de8d402017-05-07 17:08:04 -07001251
Tobias Henkel76832982017-08-01 08:37:40 +02001252.. attr:: semaphore
James E. Blair1de8d402017-05-07 17:08:04 -07001253
Tobias Henkel76832982017-08-01 08:37:40 +02001254 The following attributes are available:
1255
1256 .. attr:: name
1257 :required:
1258
1259 The name of the semaphore, referenced by jobs.
1260
1261 .. attr:: max
1262 :default: 1
1263
1264 The maximum number of running jobs which can use this semaphore.