diff --git a/src/main/java/io/jenkins/plugins/checks/api/ChecksPublisherFactory.java b/src/main/java/io/jenkins/plugins/checks/api/ChecksPublisherFactory.java index e81639ef..de58d509 100644 --- a/src/main/java/io/jenkins/plugins/checks/api/ChecksPublisherFactory.java +++ b/src/main/java/io/jenkins/plugins/checks/api/ChecksPublisherFactory.java @@ -4,6 +4,7 @@ import java.util.Optional; import edu.hm.hafner.util.VisibleForTesting; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.model.Job; import hudson.model.Run; import hudson.model.TaskListener; @@ -32,7 +33,9 @@ public abstract class ChecksPublisherFactory implements ExtensionPoint { * a listener to the builds * @return the created {@link ChecksPublisher} */ - protected abstract Optional createPublisher(Run run, TaskListener listener); + protected Optional createPublisher(final Run run, final TaskListener listener) { + return Optional.empty(); + } /** * Creates a {@link ChecksPublisher} according to the {@link hudson.scm.SCM} used by the {@link Job}. @@ -52,10 +55,22 @@ public abstract class ChecksPublisherFactory implements ExtensionPoint { * a listener to the builds * @return the created {@link ChecksPublisher} */ - protected Optional createPublisher(Job job, TaskListener listener) { + protected Optional createPublisher(final Job job, final TaskListener listener) { return Optional.empty(); } + /** + * Returns a suitable publisher for the run. + * + * @param run + * a Jenkins run + * @return a publisher suitable for the job + */ + @SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "restore to 0.1.0 version api") + public static ChecksPublisher fromRun(final Run run) { + return fromRun(run, null, new JenkinsFacade()); + } + /** * Returns a suitable publisher for the run. *