From 7848e95f1bae3d208fb7b48538b3409a9bcdd78a Mon Sep 17 00:00:00 2001 From: Tomas Bjerre Date: Wed, 4 Jul 2018 15:24:34 +0200 Subject: [PATCH] Custom template --- CHANGELOG.md | 22 ++++++++++++++++++ pom.xml | 4 ++-- run.sh | 2 +- .../ViolationsToBitbucketServerConfig.java | 23 ++++++++++++++----- .../plugins/jvctb/perform/JvctbPerformer.java | 8 +++++-- .../config.jelly | 7 ++++++ 6 files changed, 55 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdf87b5..9bfaaf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,28 @@ Changelog of Violation Comments to Bitbucket Server Plugin. +## Unreleased +### GitHub [#33](https://github.com/jenkinsci/violation-comments-to-stash-plugin/issues/33) No PR comments for Finbugs + +**NullAway #33** + + +[7d5295cf45980fe](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/7d5295cf45980fe) Tomas Bjerre *2018-04-14 05:17:26* + + +### No issue + +**Correcting license** + + +[e18a627299de812](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/e18a627299de812) Tomas Bjerre *2018-06-21 17:21:06* + +**Licenseus** + + +[e05c853098ca607](https://github.com/jenkinsci/violation-comments-to-stash-plugin/commit/e05c853098ca607) Tomas Bjerre *2018-06-14 15:28:51* + + ## 1.70 ### GitHub [#50](https://github.com/jenkinsci/violation-comments-to-stash-plugin/pull/50) Combined credentials and item always being null diff --git a/pom.xml b/pom.xml index 45b5f54..9ad7b0e 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ - 7 + 8 2.7.4 false true @@ -186,7 +186,7 @@ Changelog of Violation Comments to Bitbucket Server Plugin. se.bjurr.violations violation-comments-to-bitbucket-server-lib - 1.48 + 1.49 org.jenkins-ci.plugins diff --git a/run.sh b/run.sh index 569530d..ca1e798 100755 --- a/run.sh +++ b/run.sh @@ -1,2 +1,2 @@ #!/bin/sh -mvn -q hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.89.3 +mvn -q hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.89.3 -Denforcer.skip=true diff --git a/src/main/java/org/jenkinsci/plugins/jvctb/config/ViolationsToBitbucketServerConfig.java b/src/main/java/org/jenkinsci/plugins/jvctb/config/ViolationsToBitbucketServerConfig.java index 76bdd15..d46343d 100644 --- a/src/main/java/org/jenkinsci/plugins/jvctb/config/ViolationsToBitbucketServerConfig.java +++ b/src/main/java/org/jenkinsci/plugins/jvctb/config/ViolationsToBitbucketServerConfig.java @@ -41,6 +41,7 @@ public class ViolationsToBitbucketServerConfig private int commentOnlyChangedContentContext; private SEVERITY minSeverity; private boolean keepOldComments; + private String commentTemplate; @Deprecated private transient String username; @Deprecated private transient String password; @Deprecated private transient String usernamePasswordCredentialsId; @@ -69,6 +70,7 @@ public ViolationsToBitbucketServerConfig(final ViolationsToBitbucketServerConfig commentOnlyChangedContentContext = rhs.commentOnlyChangedContentContext; this.minSeverity = rhs.minSeverity; this.keepOldComments = rhs.keepOldComments; + this.commentTemplate = rhs.commentTemplate; } public void applyDefaults(final ViolationsToBitbucketServerGlobalConfiguration defaults) { @@ -327,6 +329,15 @@ public boolean isKeepOldComments() { return keepOldComments; } + public String getCommentTemplate() { + return commentTemplate; + } + + @DataBoundSetter + public void setCommentTemplate(final String commentTemplate) { + this.commentTemplate = commentTemplate; + } + @DataBoundSetter public void setKeepOldComments(final boolean keepOldComments) { this.keepOldComments = keepOldComments; @@ -352,17 +363,17 @@ public ListBoxModel doFillMinSeverityItems() { @SuppressWarnings("unused") // Used by stapler public ListBoxModel doFillCredentialsIdItems( - @AncestorInPath Item item, - @QueryParameter String credentialsId, - @QueryParameter String bitbucketServerUrl) { + @AncestorInPath final Item item, + @QueryParameter final String credentialsId, + @QueryParameter final String bitbucketServerUrl) { return CredentialsHelper.doFillCredentialsIdItems(item, credentialsId, bitbucketServerUrl); } @SuppressWarnings("unused") // Used by stapler public FormValidation doCheckCredentialsId( - @AncestorInPath Item item, - @QueryParameter String value, - @QueryParameter String bitbucketServerUrl) { + @AncestorInPath final Item item, + @QueryParameter final String value, + @QueryParameter final String bitbucketServerUrl) { return CredentialsHelper.doCheckFillCredentialsId(item, value, bitbucketServerUrl); } } 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 1e3122f..fd83679 100644 --- a/src/main/java/org/jenkinsci/plugins/jvctb/perform/JvctbPerformer.java +++ b/src/main/java/org/jenkinsci/plugins/jvctb/perform/JvctbPerformer.java @@ -112,16 +112,17 @@ public static void doPerform( try { final ViolationCommentsToBitbucketServerApi b = violationCommentsToBitbucketServerApi(); if (credentials instanceof StandardUsernamePasswordCredentials) { - StandardUsernamePasswordCredentials usernamePassword = + final StandardUsernamePasswordCredentials usernamePassword = (StandardUsernamePasswordCredentials) credentials; b // .withUsername(usernamePassword.getUsername()) // .withPassword(Secret.toString(usernamePassword.getPassword())); } else if (credentials instanceof StringCredentials) { - StringCredentials personalAccessToken = (StringCredentials) credentials; + final StringCredentials personalAccessToken = (StringCredentials) credentials; b // .withPersonalAccessToken(Secret.toString(personalAccessToken.getSecret())); } + final String commentTemplate = config.getCommentTemplate(); b // .withBitbucketServerUrl(config.getBitbucketServerUrl()) // .withPullRequestId(pullRequestIdInt) // @@ -134,6 +135,7 @@ public static void doPerform( .withCommentOnlyChangedContent(config.getCommentOnlyChangedContent()) // .withCommentOnlyChangedContentContext(config.getCommentOnlyChangedContentContext()) // .withShouldKeepOldComments(config.isKeepOldComments()) // + .withCommentTemplate(commentTemplate) // .toPullRequest(); } catch (final Exception e) { Logger.getLogger(JvctbPerformer.class.getName()).log(SEVERE, "", e); @@ -160,6 +162,7 @@ static ViolationsToBitbucketServerConfig expand( expanded.setCommentOnlyChangedContentContext(config.getCommentOnlyChangedContentContext()); expanded.setMinSeverity(config.getMinSeverity()); expanded.setKeepOldComments(config.isKeepOldComments()); + expanded.setCommentTemplate(config.getCommentTemplate()); for (final ViolationConfig violationConfig : config.getViolationConfigs()) { final String pattern = environment.expand(violationConfig.getPattern()); @@ -252,6 +255,7 @@ private static void logConfiguration( + config.getCommentOnlyChangedContentContext()); logger.println(FIELD_MINSEVERITY + ": " + config.getMinSeverity()); logger.println(FIELD_KEEP_OLD_COMMENTS + ": " + config.isKeepOldComments()); + logger.println("commentTemplate: " + config.getCommentTemplate()); for (final ViolationConfig violationConfig : config.getViolationConfigs()) { logger.println( diff --git a/src/main/resources/org/jenkinsci/plugins/jvctb/config/ViolationsToBitbucketServerConfig/config.jelly b/src/main/resources/org/jenkinsci/plugins/jvctb/config/ViolationsToBitbucketServerConfig/config.jelly index 0cf89a0..cf8b387 100644 --- a/src/main/resources/org/jenkinsci/plugins/jvctb/config/ViolationsToBitbucketServerConfig/config.jelly +++ b/src/main/resources/org/jenkinsci/plugins/jvctb/config/ViolationsToBitbucketServerConfig/config.jelly @@ -59,6 +59,13 @@ + + + + Optional, leave empty for default template. It is documented here. + + +