diff --git a/CHANGELOG.md b/CHANGELOG.md index c0755ae..6146a66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,20 @@ Changelog of Violation Comments to Bitbucket Server Plugin. ## Unreleased +### GitHub [#36](https://github.com/jenkinsci/violation-comments-to-stash-plugin/issues/36) java.lang.NullPointerException from violations-lib + +**Ignoring violation configs with null config #36** + + +[3371d0a64306695](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/3371d0a64306695) Tomas Bjerre *2017-08-11 10:17:17* + + ### No issue **doc** -[660761046a7050b](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/660761046a7050b) Tomas Bjerre *2017-08-02 15:38:11* +[5e436b254438d7f](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/5e436b254438d7f) Tomas Bjerre *2017-08-02 15:38:36* ## 1.52 diff --git a/pom.xml b/pom.xml index 9311637..dedc5b2 100644 --- a/pom.xml +++ b/pom.xml @@ -202,7 +202,7 @@ Changelog of Violation Comments to Bitbucket Server Plugin. se.bjurr.violations violation-comments-to-bitbucket-server-lib - 1.28 + 1.29 diff --git a/src/main/java/org/jenkinsci/plugins/jvctb/perform/JvctbPerformer.java b/src/main/java/org/jenkinsci/plugins/jvctb/perform/JvctbPerformer.java index c758cf1..e3d39e0 100644 --- a/src/main/java/org/jenkinsci/plugins/jvctb/perform/JvctbPerformer.java +++ b/src/main/java/org/jenkinsci/plugins/jvctb/perform/JvctbPerformer.java @@ -23,6 +23,7 @@ import static se.bjurr.violations.comments.bitbucketserver.lib.ViolationCommentsToBitbucketServerApi.violationCommentsToBitbucketServerApi; import static se.bjurr.violations.lib.ViolationsReporterApi.violationsReporterApi; import static se.bjurr.violations.lib.parsers.FindbugsParser.setFindbugsMessagesXml; +import static se.bjurr.violations.lib.util.Filtering.withAtLEastSeverity; import hudson.EnvVars; import hudson.FilePath; import hudson.FilePath.FileCallable; @@ -46,7 +47,7 @@ import se.bjurr.violations.lib.model.SEVERITY; import se.bjurr.violations.lib.model.Violation; -import se.bjurr.violations.lib.util.Filtering; +import se.bjurr.violations.lib.reports.Parser; import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; import com.google.common.annotations.VisibleForTesting; @@ -54,6 +55,7 @@ import com.google.common.io.CharStreams; public class JvctbPerformer { + private static Logger LOG = Logger.getLogger(JvctbPerformer.class.getSimpleName()); @VisibleForTesting public static void doPerform( @@ -80,9 +82,9 @@ public static void doPerform( .inFolder(workspace.getAbsolutePath()) // .withPattern(violationConfig.getPattern()) // .violations(); - SEVERITY minSeverity = config.getMinSeverity(); + final SEVERITY minSeverity = config.getMinSeverity(); if (minSeverity != null) { - parsedViolations = Filtering.withAtLEastSeverity(parsedViolations, minSeverity); + parsedViolations = withAtLEastSeverity(parsedViolations, minSeverity); } allParsedViolations.addAll(parsedViolations); @@ -153,10 +155,17 @@ static ViolationsToBitbucketServerConfig expand( expanded.setMinSeverity(config.getMinSeverity()); for (final ViolationConfig violationConfig : config.getViolationConfigs()) { + final String pattern = environment.expand(violationConfig.getPattern()); + final String reporter = violationConfig.getReporter(); + final Parser parser = violationConfig.getParser(); + if (isNullOrEmpty(pattern) || isNullOrEmpty(reporter) || parser == null) { + LOG.fine("Ignoring violationConfig because of null/empty -values: " + violationConfig); + continue; + } final ViolationConfig p = new ViolationConfig(); - p.setPattern(environment.expand(violationConfig.getPattern())); - p.setReporter(violationConfig.getReporter()); - p.setParser(violationConfig.getParser()); + p.setPattern(pattern); + p.setReporter(reporter); + p.setParser(parser); expanded.getViolationConfigs().add(p); } return expanded; @@ -209,7 +218,7 @@ private static void logConfiguration( final ViolationsToBitbucketServerConfig config, final Run build, final TaskListener listener) { - PrintStream logger = listener.getLogger(); + final PrintStream logger = listener.getLogger(); logger.println(FIELD_BITBUCKETSERVERURL + ": " + config.getBitbucketServerUrl()); logger.println(FIELD_PROJECTKEY + ": " + config.getProjectKey()); logger.println(FIELD_REPOSLUG + ": " + config.getRepoSlug());