diff --git a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/Phase.java b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/Phase.java index 2797ee2..6518e5e 100644 --- a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/Phase.java +++ b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/Phase.java @@ -40,12 +40,15 @@ public enum Phase { @SuppressWarnings({ "unchecked", "rawtypes" }) public String handlePhase(Run run, String status, TaskListener listener) { - HudsonNotificationProperty property = (HudsonNotificationProperty) run.getParent().getProperty(HudsonNotificationProperty.class); - if (property != null) { - HudsonNotificationProperty.HudsonNotificationPropertyDescriptor globalProperty = property.getDescriptor(); - if (globalProperty.isGloballyEnabled() || property.isEnabled()) { - return buildMessage(run.getParent(), run, status); - } + Hudson hudson = Hudson.getInstance(); + HudsonNotificationProperty property = (HudsonNotificationProperty) + run.getParent().getProperty(HudsonNotificationProperty.class); + HudsonNotificationProperty.HudsonNotificationPropertyDescriptor globalProperty = + (HudsonNotificationProperty.HudsonNotificationPropertyDescriptor) + hudson.getDescriptor(HudsonNotificationProperty.class); + if ((property != null && property.isEnabled()) || + (globalProperty != null && globalProperty.isGloballyEnabled())) { + return buildMessage(run.getParent(), run, status); } return null; } diff --git a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/RunListenerImpl.java b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/RunListenerImpl.java index 4d19a84..c71d48e 100644 --- a/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/RunListenerImpl.java +++ b/src/main/java/org/jenkinsci/plugins/ZMQEventPublisher/RunListenerImpl.java @@ -19,6 +19,7 @@ package org.jenkinsci.plugins.ZMQEventPublisher; import hudson.Extension; import hudson.EnvVars; +import hudson.model.Hudson; import hudson.model.Result; import hudson.model.Run; import hudson.model.TaskListener; @@ -48,9 +49,11 @@ public class RunListenerImpl extends RunListener { } private int getPort(Run build) { - HudsonNotificationProperty property = (HudsonNotificationProperty) build.getParent().getProperty(HudsonNotificationProperty.class); - if (property != null) { - HudsonNotificationProperty.HudsonNotificationPropertyDescriptor globalProperty = property.getDescriptor(); + Hudson hudson = Hudson.getInstance(); + HudsonNotificationProperty.HudsonNotificationPropertyDescriptor globalProperty = + (HudsonNotificationProperty.HudsonNotificationPropertyDescriptor) + hudson.getDescriptor(HudsonNotificationProperty.class); + if (globalProperty != null) { return globalProperty.getPort(); } return 8888;