Skip to content

Commit

Permalink
Refactor: Prepare modularisation of triggerSCM method
Browse files Browse the repository at this point in the history
  • Loading branch information
solarlodge committed Sep 19, 2023
1 parent 798cdae commit 9aa388a
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<SCM> scmTriggered;

public BitBucketPPRJobProbe() {
scmTriggered = new ArrayList<>();
}

public void triggerMatchingJobs(BitBucketPPRHookEvent bitbucketEvent,
BitBucketPPRAction bitbucketAction, BitBucketPPRObservable observable) {

Expand Down Expand Up @@ -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) {
Expand All @@ -139,6 +147,16 @@ && mPJobShouldNotBeTriggered(job, bitbucketEvent, bitbucketAction)) {
}));
}

private static class Trigger {
public final BitBucketPPRTrigger bitbucketTrigger;
public final Optional<SCMTriggerItem> scmTriggerItem;

public Trigger(BitBucketPPRTrigger bitbucketTrigger, Optional<SCMTriggerItem> item) {
this.bitbucketTrigger = bitbucketTrigger;
this.scmTriggerItem = item;
}
}

private boolean mPJobShouldNotBeTriggered(Job<?, ?> job, BitBucketPPRHookEvent bitbucketEvent,
BitBucketPPRAction bitbucketAction) {

Expand Down

0 comments on commit 9aa388a

Please sign in to comment.