From 9aa388aad5a98ee356c4b3c614be62c1e3b892e6 Mon Sep 17 00:00:00 2001 From: Christian Brauchmann Date: Tue, 19 Sep 2023 10:27:08 +0200 Subject: [PATCH] Refactor: Prepare modularisation of triggerSCM method --- .../BitBucketPPRJobProbe.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRJobProbe.java b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRJobProbe.java index 95e4336..a516721 100644 --- a/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRJobProbe.java +++ b/src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/BitBucketPPRJobProbe.java @@ -64,6 +64,14 @@ public class BitBucketPPRJobProbe { private static final Logger logger = Logger.getLogger(BitBucketPPRJobProbe.class.getName()); + private static final BitBucketPPRPluginConfig globalConfig = + BitBucketPPRPluginConfig.getInstance(); + private final List scmTriggered; + + public BitBucketPPRJobProbe() { + scmTriggered = new ArrayList<>(); + } + public void triggerMatchingJobs(BitBucketPPRHookEvent bitbucketEvent, BitBucketPPRAction bitbucketAction, BitBucketPPRObservable observable) { @@ -124,7 +132,7 @@ && mPJobShouldNotBeTriggered(job, bitbucketEvent, bitbucketAction)) { scmTriggered.add(scmTrigger); try { - bitbucketTrigger.onPost(bitbucketEvent, bitbucketAction, scmTrigger, observable); + trigger.bitbucketTrigger.onPost(bitbucketEvent, bitbucketAction, scmTrigger, observable); return; } catch (Throwable e) { @@ -139,6 +147,16 @@ && mPJobShouldNotBeTriggered(job, bitbucketEvent, bitbucketAction)) { })); } + private static class Trigger { + public final BitBucketPPRTrigger bitbucketTrigger; + public final Optional scmTriggerItem; + + public Trigger(BitBucketPPRTrigger bitbucketTrigger, Optional item) { + this.bitbucketTrigger = bitbucketTrigger; + this.scmTriggerItem = item; + } + } + private boolean mPJobShouldNotBeTriggered(Job job, BitBucketPPRHookEvent bitbucketEvent, BitBucketPPRAction bitbucketAction) {