Skip to content

Commit

Permalink
Exception logging in build job log
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Sep 18, 2018
1 parent 72cb6e4 commit 081a82d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion debug.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
mvnDebug -q hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.89.3 -Denforcer.skip=true
mvnDebug -q hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.121.3 -Denforcer.skip=true

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,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.61</version>
<version>1.62</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
mvn -q hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.89.3 -Denforcer.skip=true
mvn -q hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.121.3 -Denforcer.skip=true
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jenkinsci.plugins.jvctb.ProxyConfigDetails;
import org.jenkinsci.plugins.jvctb.config.ViolationConfig;
import org.jenkinsci.plugins.jvctb.config.ViolationsToBitbucketServerConfig;
import org.jenkinsci.plugins.plaincredentials.StringCredentials;
import org.jenkinsci.remoting.RoleChecker;
import se.bjurr.violations.comments.bitbucketserver.lib.ViolationCommentsToBitbucketServerApi;
import se.bjurr.violations.comments.lib.ViolationsLogger;
import se.bjurr.violations.lib.model.SEVERITY;
import se.bjurr.violations.lib.model.Violation;
import se.bjurr.violations.lib.reports.Parser;
Expand Down Expand Up @@ -144,7 +146,20 @@ public static void doPerform(
.withCommentOnlyChangedContentContext(config.getCommentOnlyChangedContentContext()) //
.withShouldKeepOldComments(config.isKeepOldComments()) //
.withCommentTemplate(commentTemplate) //
.withViolationsLogger(string -> listener.getLogger().println(string)) //
.withViolationsLogger(
new ViolationsLogger() {
@Override
public void log(final Level level, final String string) {
listener.getLogger().println(level + " " + string);
}

@Override
public void log(final Level level, final String string, final Throwable t) {
final StringWriter sw = new StringWriter();
t.printStackTrace(new PrintWriter(sw));
listener.getLogger().println(level + " " + sw.toString());
}
}) //
.toPullRequest();
} catch (final Exception e) {
Logger.getLogger(JvctbPerformer.class.getName()).log(SEVERE, "", e);
Expand Down

0 comments on commit 081a82d

Please sign in to comment.