From 3371d0a64306695f4fb353b2a69844825a69a35b Mon Sep 17 00:00:00 2001 From: Tomas Bjerre Date: Fri, 11 Aug 2017 12:17:17 +0200 Subject: [PATCH] Ignoring violation configs with null config #36 --- CHANGELOG.md | 2 +- pom.xml | 2 +- .../plugins/jvctb/perform/JvctbPerformer.java | 20 +++++++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0755ae..5f04fb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Changelog of Violation Comments to Bitbucket Server Plugin. **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..273c15b 100644 --- a/src/main/java/org/jenkinsci/plugins/jvctb/perform/JvctbPerformer.java +++ b/src/main/java/org/jenkinsci/plugins/jvctb/perform/JvctbPerformer.java @@ -46,6 +46,7 @@ import se.bjurr.violations.lib.model.SEVERITY; import se.bjurr.violations.lib.model.Violation; +import se.bjurr.violations.lib.reports.Parser; import se.bjurr.violations.lib.util.Filtering; import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; @@ -54,7 +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( final ViolationsToBitbucketServerConfig config, @@ -80,7 +81,7 @@ 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); } @@ -153,10 +154,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 +217,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());