Skip to content

Commit

Permalink
Custom template
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Jul 4, 2018
1 parent e18a627 commit 7848e95
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 11 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<properties>
<java.level>7</java.level>
<java.level>8</java.level>
<jenkins.version>2.7.4</jenkins.version>
<findbugs.failOnError>false</findbugs.failOnError>
<maven.javadoc.skip>true</maven.javadoc.skip>
Expand Down 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.48</version>
<version>1.49</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
mvn -q hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.89.3 -Denforcer.skip=true
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) //
Expand All @@ -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);
Expand All @@ -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());
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
</f:description>
</f:optionalBlock>

<f:entry title="Comment template" field="commentTemplate">
<f:textarea style="width: 500px; height: 200px"/>
<f:description>
Optional, leave empty for default template. It is documented <a href="https://github.com/tomasbjerre/violation-comments-lib" targe="_blank">here</a>.
</f:description>
</f:entry>

<f:entry>
<table class="xmlFilenamePatterns" cellspacing="5">
<tr>
Expand Down

0 comments on commit 7848e95

Please sign in to comment.