Skip to content

Commit

Permalink
Ignoring violation configs with null config #36
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Aug 11, 2017
1 parent 5e436b2 commit 3371d0a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Changelog of Violation Comments to Bitbucket Server Plugin.
<dependency>
<groupId>se.bjurr.violations</groupId>
<artifactId>violation-comments-to-bitbucket-server-lib</artifactId>
<version>1.28</version>
<version>1.29</version>
</dependency>

<!-- test // -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 3371d0a

Please sign in to comment.