summaryrefslogtreecommitdiff
path: root/doc/source/drivers/pagure.rst
blob: 7845ae79ac59329790355a34bb70d63ee4b9f35b (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
:title: Pagure Driver

.. _pagure_driver:

Pagure
======

The Pagure driver supports sources, triggers, and reporters.  It can
interact with the public Pagure.io service as well as site-local
installations of Pagure.

Configure Pagure
----------------

The user's API token configured in zuul.conf must have the following
ACL rights:

- "Merge a pull-request" set to on (optional, only for gating)
- "Flag a pull-request" set to on
- "Comment on a pull-request" set to on
- "Modify an existing project" set to on

Each project to be integrated with Zuul needs:

- "Web hook target" set to
  http://<zuul-web>/zuul/api/connection/<conn-name>/payload
- "Pull requests" set to on
- "Open metadata access to all" set to off (optional, expected if approval
  based on PR a metadata tag)
- "Minimum score to merge pull-request" set to the same value than
  the score requierement (optional, expected if score requierement is
  defined in a pipeline)

Furthermore, the user must be added as project collaborator
(**ticket** access level), to be able to read the project's
webhook token. This token is used to validate webhook's payload. But
if Zuul is configured to merge pull requests then the access level
must be **commit**.

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

The supported options in ``zuul.conf`` connections are:

.. attr:: <pagure connection>

   .. attr:: driver
      :required:

      .. value:: pagure

         The connection must set ``driver=pagure`` for Pagure connections.

   .. attr:: api_token

      The user's API token with the ``Modify an existing project`` capability.

   .. attr:: server
      :default: pagure.io

      Hostname of the Pagure server.

   .. attr:: canonical_hostname

      The canonical hostname associated with the git repos on the
      Pagure server.  Defaults to the value of :attr:`<pagure
      connection>.server`.  This is used to identify projects from
      this connection by name and in preparing repos on the filesystem
      for use by jobs.  Note that Zuul will still only communicate
      with the Pagure server identified by **server**; this option is
      useful if users customarily use a different hostname to clone or
      pull git repos so that when Zuul places them in the job's
      working directory, they appear under this directory name.

   .. attr:: baseurl
      :default: https://{server}

      Path to the Pagure web and API interface.

   .. attr:: cloneurl
      :default: https://{baseurl}

      Path to the Pagure Git repositories. Used to clone.

   .. attr:: app_name
      :default: Zuul

      Display name that will appear as the application name in front
      of each CI status flag.

   .. attr:: source_whitelist
      :default: ''

      A comma separated list of source ip adresses from which webhook
      calls are whitelisted. If the source is not whitelisted, then
      call payload's signature is verified using the project webhook
      token. An admin access to the project is required by Zuul to read
      the token. White listing a source of hook calls allows Zuul to
      react to events without any authorizations. This setting should
      not be used in production.


Trigger Configuration
---------------------
Pagure webhook events can be configured as triggers.

A connection name with the Pagure driver can take multiple events with
the following options.

.. attr:: pipeline.trigger.<pagure source>

   The dictionary passed to the Pagure pipeline ``trigger`` attribute
   supports the following attributes:

   .. attr:: event
      :required:

      The event from Pagure. Supported events are:

      .. value:: pg_pull_request

      .. value:: pg_pull_request_review

      .. value:: pg_push

   .. attr:: action

      A :value:`pipeline.trigger.<pagure source>.event.pg_pull_request`
      event will have associated action(s) to trigger from. The
      supported actions are:

      .. value:: opened

         Pull request opened.

      .. value:: changed

         Pull request synchronized.

      .. value:: closed

         Pull request closed.

      .. value:: comment

         Comment added to pull request.

      .. value:: status

         Status set on pull request.

      .. value:: tagged

         Tag metadata set on pull request.

      A :value:`pipeline.trigger.<pagure
      source>.event.pg_pull_request_review` event will have associated
      action(s) to trigger from. The supported actions are:

      .. value:: thumbsup

         Positive pull request review added.

      .. value:: thumbsdown

         Negative pull request review added.

   .. attr:: comment

      This is only used for ``pg_pull_request`` and ``comment`` actions.  It
      accepts a list of regexes that are searched for in the comment
      string. If any of these regexes matches a portion of the comment
      string the trigger is matched.  ``comment: retrigger`` will
      match when comments containing 'retrigger' somewhere in the
      comment text are added to a pull request.

   .. attr:: status

      This is used for ``pg_pull_request`` and ``status`` actions. It
      accepts a list of strings each of which matches the user setting
      the status, the status context, and the status itself in the
      format of ``status``.  For example, ``success`` or ``failure``.

   .. attr:: tag

      This is used for ``pg_pull_request`` and ``tagged`` actions. It
      accepts a list of strings and if one of them is part of the
      event tags metadata then the trigger is matched.

   .. attr:: ref

      This is only used for ``pg_push`` events. This field is treated as
      a regular expression and multiple refs may be listed. Pagure
      always sends full ref name, eg. ``refs/tags/bar`` and this
      string is matched against the regular expression.

Reporter Configuration
----------------------
Zuul reports back to Pagure via Pagure API. Available reports include a PR
comment containing the build results, a commit status on start, success and
failure, and a merge of the PR itself. Status name, description, and context
is taken from the pipeline.

.. attr:: pipeline.<reporter>.<pagure source>

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

   .. attr:: status

      String value (``pending``, ``success``, ``failure``) that the
      reporter should set as the commit status on Pagure.

   .. attr:: status-url
      :default: web.status_url or the empty string

      String value for a link url to set in the Pagure status. Defaults to the
      zuul server status_url, or the empty string if that is unset.

   .. attr:: comment
      :default: true

      Boolean value that determines if the reporter should add a
      comment to the pipeline status to the Pagure Pull Request. Only
      used for Pull Request based items.

   .. attr:: merge
      :default: false

      Boolean value that determines if the reporter should merge the
      pull Request. Only used for Pull Request based items.


Requirements Configuration
--------------------------

As described in :attr:`pipeline.require` pipelines may specify that items meet
certain conditions in order to be enqueued into the pipeline.  These conditions
vary according to the source of the project in question.  To supply
requirements for changes from a Pagure source named ``pagure``, create a
configuration such as the following:

.. code-block:: yaml

   pipeline:
     require:
       pagure:
         score: 1
         merged: false
         status: success
         tags:
           - gateit

This indicates that changes originating from the Pagure connection
must have a score of *1*, a CI status *success* and not being already merged.

.. attr:: pipeline.require.<pagure source>

   The dictionary passed to the Pagure pipeline `require` attribute
   supports the following attributes:

   .. attr:: score

      If present, the minimal score a Pull Request must reached.

   .. attr:: status

      If present, the CI status a Pull Request must have.

   .. attr:: merged

      A boolean value (``true`` or ``false``) that indicates whether
      the Pull Request must be merged or not in order to be enqueued.

   .. attr:: open

      A boolean value (``true`` or ``false``) that indicates whether
      the Pull Request must be open or closed in order to be enqueued.

   .. attr:: tags

      if present, the list of tags a Pull Request must have.


Reference pipelines configuration
---------------------------------

Here is an example of standard pipelines you may want to define:

.. literalinclude:: /examples/pipelines/pagure-reference-pipelines.yaml
   :language: yaml