summaryrefslogtreecommitdiff
path: root/doc/source/drivers/mqtt.rst
blob: 81969ae8bac7163ac51ab2b952993a42fd7bda10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
:title: MQTT Driver

MQTT
====

The MQTT driver supports reporters only. It is used to send MQTT
message when items report.

Message Schema
--------------

An MQTT report uses this schema:

.. attr:: <mqtt schema>

   .. attr:: uuid

      The item UUID.  Each item enqueued into a Zuul pipeline is
      assigned a UUID which remains the same even as Zuul's
      speculative execution algorithm re-orders pipeline contents.

   .. attr:: action

      The reporter action name, e.g.: 'start', 'success', 'failure',
      'merge-conflict', ...

   .. attr:: tenant

      The tenant name.

   .. attr:: pipeline

      The pipeline name.

   .. attr:: project

      The project name.

   .. attr:: branch

      The branch name.

   .. attr:: change_url

      The change url.

   .. attr:: message

      The report message.

   .. attr:: change

      The change number.

   .. attr:: patchset

      The patchset number.

   .. attr:: commit_id

      The commit id number.

   .. attr:: owner

      The owner username of the change.

   .. attr:: ref

      The change reference.

   .. attr:: zuul_ref

      The internal zuul change reference.

   .. attr:: trigger_time

      The timestamp when the event was added to the scheduler.

   .. attr:: enqueue_time

      The timestamp when the event was added to the pipeline.

   .. attr:: buildset

      The buildset information.

      .. value:: uuid

      The buildset global uuid.

      .. attr:: result

      The buildset result

      .. attr:: builds

         The list of builds.

         .. attr:: job_name

            The job name.

         .. attr:: voting

            The job voting status.

         .. attr:: uuid

            The build uuid (not present in start report).

         .. attr:: execute_time

            The build execute time.

         .. attr:: start_time

            The build start time (not present in start report).

         .. attr:: end_time

            The build end time (not present in start report).

         .. attr:: log_url

            The build log url (not present in start report).

         .. attr:: web_url

            The url to the build result page.  Not present in start
            report.

         .. attr:: result

            The build results (not present in start report).

         .. attr:: artifacts
            :type: list

            The build artifacts (not present in start report).

            This is a list of dictionaries corresponding to the returned artifacts.

            .. attr:: name

               The name of the artifact.

            .. attr:: url

               The url of the artifact.

            .. attr:: metadata
               :type: dict

               The metadata of the artifact.  This is a dictionary of
               arbitrary key values determined by the job.

Here is an example of a start message:

.. code-block:: javascript

  {
    'action': 'start',
    'tenant': 'openstack.org',
    'pipeline': 'check',
    'project': 'sf-jobs',
    'branch': 'master',
    'change_url': 'https://gerrit.example.com/r/3',
    'message': 'Starting check jobs.',
    'trigger_time': '1524801056.2545864',
    'enqueue_time': '1524801093.5689457',
    'change': '3',
    'patchset': '1',
    'commit_id': '2db20c7fb26adf9ac9936a9e750ced9b4854a964',
    'owner': 'username',
    'ref': 'refs/changes/03/3/1',
    'zuul_ref': 'Zf8b3d7cd34f54cb396b488226589db8f',
    'buildset': {
      'uuid': 'f8b3d7cd34f54cb396b488226589db8f',
      'builds': [{
        'job_name': 'linters',
        'voting': True
      }],
    },
  }


Here is an example of a success message:

.. code-block:: javascript

  {
    'action': 'success',
    'tenant': 'openstack.org',
    'pipeline': 'check',
    'project': 'sf-jobs',
    'branch': 'master',
    'change_url': 'https://gerrit.example.com/r/3',
    'message': 'Build succeeded.',
    'trigger_time': '1524801056.2545864',
    'enqueue_time': '1524801093.5689457',
    'change': '3',
    'patchset': '1',
    'commit_id': '2db20c7fb26adf9ac9936a9e750ced9b4854a964',
    'owner': 'username',
    'ref': 'refs/changes/03/3/1',
    'zuul_ref': 'Zf8b3d7cd34f54cb396b488226589db8f',
    'buildset': {
      'uuid': 'f8b3d7cd34f54cb396b488226589db8f',
      'builds': [{
        'job_name': 'linters',
        'voting': True
        'uuid': '16e3e55aca984c6c9a50cc3c5b21bb83',
        'execute_time': 1524801120.75632954,
        'start_time': 1524801179.8557224,
        'end_time': 1524801208.928095,
        'log_url': 'https://logs.example.com/logs/3/3/1/check/linters/16e3e55/',
        'web_url': 'https://tenant.example.com/t/tenant-one/build/16e3e55aca984c6c9a50cc3c5b21bb83/',
        'result': 'SUCCESS',
        'dependencies': [],
        'artifacts': [],
      }],
    },
  }


Connection Configuration
------------------------

.. attr:: <mqtt connection>

   .. attr:: driver
      :required:

      .. value:: mqtt

         The connection must set ``driver=mqtt`` for MQTT connections.

   .. attr:: server
      :default: localhost

      MQTT server hostname or address to use.

   .. attr:: port
      :default: 1883

      MQTT server port.

   .. attr:: keepalive
      :default: 60

      Maximum period in seconds allowed between communications with the broker.

   .. attr:: user

      Set a username for optional broker authentication.

   .. attr:: password

      Set a password for optional broker authentication.

   .. attr:: ca_certs

      A string path to the Certificate Authority certificate files to enable
      TLS connection.

   .. attr:: certfile

      A strings pointing to the PEM encoded client certificate to
      enable client TLS based authentication. This option requires keyfile to
      be set too.

   .. attr:: keyfile

      A strings pointing to the PEM encoded client private keys to
      enable client TLS based authentication. This option requires certfile to
      be set too.

   .. attr:: ciphers

      A string specifying which encryption ciphers are allowable for this
      connection. More information in this
      `openssl doc <https://www.openssl.org/docs/manmaster/man1/ciphers.html>`_.


Reporter Configuration
----------------------

A :ref:`connection<connections>` that uses the mqtt driver must be supplied to the
reporter. Each pipeline must provide a topic name. For example:

.. code-block:: yaml

   - pipeline:
       name: check
       success:
         mqtt:
           topic: "{tenant}/zuul/{pipeline}/{project}/{branch}/{change}"
           qos: 2


.. attr:: pipeline.<reporter>.<mqtt>

   To report via MQTT message, the dictionaries passed to any of the pipeline
   :ref:`reporter<reporters>` support the following attributes:

   .. attr:: topic

      The MQTT topic to publish messages. The topic can be a format string that
      can use the following parameters: ``tenant``, ``pipeline``, ``project``,
      ``branch``, ``change``, ``patchset`` and ``ref``.
      MQTT topic can have hierarchy separated by ``/``, more details in this
      `doc <https://mosquitto.org/man/mqtt-7.html>`_

   .. attr:: qos
      :default: 0

      The quality of service level to use, it can be 0, 1 or 2. Read more in this
      `guide <https://www.hivemq.com/blog/mqtt-essentials-part-6-mqtt-quality-of-service-levels>`_

   .. attr:: include-returned-data
      :default: false

      If set to ``true``, Zuul will include any data returned from the
      job via :ref:`return_values`.