@@ -206,12 +206,17 @@ def execute_action(
206
206
request : bugzilla_models .WebhookRequest ,
207
207
actions : Actions ,
208
208
):
209
- """Execute the configured action for the specified `request`.
209
+ """Execute the configured actions for the specified `request`.
210
+
211
+ If multiple actions are configured for a given request, all of them
212
+ are executed.
210
213
211
214
This will raise an `IgnoreInvalidRequestError` error if the request
212
215
does not contain bug data or does not match any action.
213
216
214
- The value returned by the action call is returned.
217
+ A dictionary containing the values returned by the actions calls
218
+ is returned. The action tag is used to index the responses in the
219
+ dictionary.
215
220
"""
216
221
bug , event = request .bug , request .event
217
222
runner_context = RunnerContext (
@@ -224,7 +229,7 @@ def execute_action(
224
229
raise IgnoreInvalidRequestError ("private bugs are not supported" )
225
230
226
231
try :
227
- action = lookup_actions (bug , actions )[ 0 ]
232
+ relevant_actions = lookup_actions (bug , actions )
228
233
except ActionNotFoundError as err :
229
234
raise IgnoreInvalidRequestError (
230
235
f"no bug whiteboard matching action tags: { err } "
@@ -243,8 +248,42 @@ def execute_action(
243
248
244
249
runner_context = runner_context .update (bug = bug )
245
250
246
- runner_context = runner_context .update (actions = [action ])
251
+ runner_context = runner_context .update (actions = relevant_actions )
252
+
253
+ return do_execute_actions (runner_context , bug , relevant_actions )
254
+ except IgnoreInvalidRequestError as exception :
255
+ logger .info (
256
+ "Ignore incoming request: %s" ,
257
+ exception ,
258
+ extra = runner_context .update (operation = Operation .IGNORE ).model_dump (),
259
+ )
260
+ statsd .incr ("jbi.bugzilla.ignored.count" )
261
+ raise
262
+
263
+
264
+ @statsd .timer ("jbi.action.execution.timer" )
265
+ def do_execute_actions (
266
+ runner_context : RunnerContext ,
267
+ bug : bugzilla_models .Bug ,
268
+ actions : Actions ,
269
+ ):
270
+ """Execute the provided actions on the bug, within the provided context.
271
+
272
+ This will raise an `IgnoreInvalidRequestError` error if the request
273
+ does not contain bug data or does not match any action.
274
+
275
+ A dictionary containing the values returned by the actions calls
276
+ is returned. The action tag is used to index the responses in the
277
+ dictionary.
278
+ """
279
+ runner_context = runner_context .update (bug = bug )
280
+
281
+ runner_context = runner_context .update (actions = actions )
247
282
283
+ event = runner_context .event
284
+
285
+ details = {}
286
+ for action in actions :
248
287
linked_issue_key : Optional [str ] = bug .extract_from_see_also (
249
288
project_key = action .jira_project_key
250
289
)
@@ -309,7 +348,8 @@ def execute_action(
309
348
extra = runner_context .update (operation = Operation .EXECUTE ).model_dump (),
310
349
)
311
350
executor = Executor (parameters = action .parameters )
312
- handled , details = executor (context = action_context )
351
+ handled , action_details = executor (context = action_context )
352
+ details [action .whiteboard_tag ] = action_details
313
353
statsd .incr (f"jbi.operation.{ action_context .operation .lower ()} .count" )
314
354
logger .info (
315
355
"Action %r executed successfully for Bug %s" ,
@@ -320,12 +360,4 @@ def execute_action(
320
360
).model_dump (),
321
361
)
322
362
statsd .incr ("jbi.bugzilla.processed.count" )
323
- return details
324
- except IgnoreInvalidRequestError as exception :
325
- logger .info (
326
- "Ignore incoming request: %s" ,
327
- exception ,
328
- extra = runner_context .update (operation = Operation .IGNORE ).model_dump (),
329
- )
330
- statsd .incr ("jbi.bugzilla.ignored.count" )
331
- raise
363
+ return details
0 commit comments