Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 22 additions & 71 deletions src/main/java/hudson/plugins/jira/JiraSite.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,17 @@
* URL of Jira for normal access, like {@code http://jira.codehaus.org/}.
* Mandatory. Normalized to end with '/'
*/
public URL alternativeUrl;

Check warning on line 129 in src/main/java/hudson/plugins/jira/JiraSite.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make alternativeUrl a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=jenkinsci_jira-plugin&issues=AZ09t7SRoxp4O0LdMqdh&open=AZ09t7SRoxp4O0LdMqdh&pullRequest=562

/**
* Jira requires HTTP Authentication for login
*/
public boolean useHTTPAuth;

/**
* The id of the credentials to use. Optional.
*/
public String credentialsId;

Check warning on line 134 in src/main/java/hudson/plugins/jira/JiraSite.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make credentialsId a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=jenkinsci_jira-plugin&issues=AZ09t7SRoxp4O0LdMqdi&open=AZ09t7SRoxp4O0LdMqdi&pullRequest=562

/**
* Jira requires Bearer Authentication for login
*/
public boolean useBearerAuth;

Check warning on line 139 in src/main/java/hudson/plugins/jira/JiraSite.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make useBearerAuth a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=jenkinsci_jira-plugin&issues=AZ09t7SRoxp4O0LdMqdj&open=AZ09t7SRoxp4O0LdMqdj&pullRequest=562

/**
* User name needed to login. Optional.
Expand All @@ -160,31 +155,31 @@
/**
* Group visibility to constrain the visibility of the added comment. Optional.
*/
public String groupVisibility;

Check warning on line 158 in src/main/java/hudson/plugins/jira/JiraSite.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make groupVisibility a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=jenkinsci_jira-plugin&issues=AZ09t7SRoxp4O0LdMqdk&open=AZ09t7SRoxp4O0LdMqdk&pullRequest=562

/**
* Role visibility to constrain the visibility of the added comment. Optional.
*/
public String roleVisibility;

Check warning on line 163 in src/main/java/hudson/plugins/jira/JiraSite.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make roleVisibility a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=jenkinsci_jira-plugin&issues=AZ09t7SRoxp4O0LdMqdl&open=AZ09t7SRoxp4O0LdMqdl&pullRequest=562

/**
* True if this Jira is configured to allow Confluence-style Wiki comment.
*/
public boolean supportsWikiStyleComment;

Check warning on line 168 in src/main/java/hudson/plugins/jira/JiraSite.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make supportsWikiStyleComment a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=jenkinsci_jira-plugin&issues=AZ09t7SRoxp4O0LdMqdm&open=AZ09t7SRoxp4O0LdMqdm&pullRequest=562

/**
* to record scm changes in jira issue
*
* @since 1.21
*/
public boolean recordScmChanges;

Check warning on line 175 in src/main/java/hudson/plugins/jira/JiraSite.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make recordScmChanges a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=jenkinsci_jira-plugin&issues=AZ09t7SRoxp4O0LdMqdn&open=AZ09t7SRoxp4O0LdMqdn&pullRequest=562

/**
* Disable annotating the changelogs
*
* @since todo
*/
public boolean disableChangelogAnnotations;

Check warning on line 182 in src/main/java/hudson/plugins/jira/JiraSite.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make disableChangelogAnnotations a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=jenkinsci_jira-plugin&issues=AZ09t7SRoxp4O0LdMqdo&open=AZ09t7SRoxp4O0LdMqdo&pullRequest=562

/**
* user defined pattern
Expand All @@ -200,12 +195,12 @@
*
* @since 1.22
*/
public boolean updateJiraIssueForAllStatus;

Check warning on line 198 in src/main/java/hudson/plugins/jira/JiraSite.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make updateJiraIssueForAllStatus a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=jenkinsci_jira-plugin&issues=AZ09t7SRoxp4O0LdMqdp&open=AZ09t7SRoxp4O0LdMqdp&pullRequest=562

/**
* connection timeout used when calling jira rest api, in seconds
*/
public int timeout = DEFAULT_TIMEOUT;

Check warning on line 203 in src/main/java/hudson/plugins/jira/JiraSite.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make timeout a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=jenkinsci_jira-plugin&issues=AZ09t7SRoxp4O0LdMqdq&open=AZ09t7SRoxp4O0LdMqdq&pullRequest=562

/**
* response timeout for jira rest call
Expand Down Expand Up @@ -252,7 +247,7 @@
private static ExecutorService executorService;

// Deprecate the previous constructor but leave it in place for Java-level compatibility.
@Deprecated
// Contruct Test succeeded in JiraSiteTest.java, removal attempt for the first time.
public JiraSite(
URL url,
@CheckForNull URL alternativeUrl,
Expand All @@ -263,7 +258,7 @@
boolean updateJiraIssueForAllStatus,
@CheckForNull String groupVisibility,
@CheckForNull String roleVisibility,
boolean useHTTPAuth) {
boolean useBearerAuth) {
this(
url,
alternativeUrl,
Expand All @@ -274,14 +269,14 @@
updateJiraIssueForAllStatus,
groupVisibility,
roleVisibility,
useHTTPAuth,
useBearerAuth,
DEFAULT_TIMEOUT,
DEFAULT_READ_TIMEOUT,
DEFAULT_THREAD_EXECUTOR_NUMBER);
}

// Deprecate the previous constructor but leave it in place for Java-level compatibility.
@Deprecated
// Contruct Test succeeded in JiraSiteTest.java, removal attempt for the first time.
public JiraSite(
URL url,
@CheckForNull URL alternativeUrl,
Expand All @@ -293,7 +288,7 @@
boolean updateJiraIssueForAllStatus,
@CheckForNull String groupVisibility,
@CheckForNull String roleVisibility,
boolean useHTTPAuth) {
boolean useBearerAuth) {
this(
url,
alternativeUrl,
Expand All @@ -304,11 +299,11 @@
updateJiraIssueForAllStatus,
groupVisibility,
roleVisibility,
useHTTPAuth);
useBearerAuth);
}

// Deprecate the previous constructor but leave it in place for Java-level compatibility.
@Deprecated
// Contruct Test succeeded in JiraSiteTest.java, removal attempt for the first time.
public JiraSite(
URL url,
URL alternativeUrl,
Expand All @@ -319,7 +314,7 @@
boolean updateJiraIssueForAllStatus,
String groupVisibility,
String roleVisibility,
boolean useHTTPAuth) {
boolean useBearerAuth) {
this(
url,
alternativeUrl,
Expand All @@ -330,7 +325,7 @@
updateJiraIssueForAllStatus,
groupVisibility,
roleVisibility,
useHTTPAuth,
useBearerAuth,
DEFAULT_TIMEOUT,
DEFAULT_READ_TIMEOUT,
DEFAULT_THREAD_EXECUTOR_NUMBER);
Expand All @@ -347,7 +342,7 @@
}

// Deprecate the previous constructor but leave it in place for Java-level compatibility.
@Deprecated
// Contruct Test succeeded in JiraSiteTest.java, removal attempt for the first time.
public JiraSite(
URL url,
URL alternativeUrl,
Expand All @@ -358,7 +353,7 @@
boolean updateJiraIssueForAllStatus,
String groupVisibility,
String roleVisibility,
boolean useHTTPAuth,
boolean useBearerAuth,
int timeout,
int readTimeout,
int threadExecutorNumber) {
Expand All @@ -382,7 +377,7 @@
this.updateJiraIssueForAllStatus = updateJiraIssueForAllStatus;
setGroupVisibility(groupVisibility);
setRoleVisibility(roleVisibility);
this.useHTTPAuth = useHTTPAuth;
this.useBearerAuth = useBearerAuth;
this.jiraSession = null;
}

Expand All @@ -396,7 +391,7 @@
}

// Deprecate the previous constructor but leave it in place for Java-level compatibility.
@Deprecated
// Contruct Test succeeded in JiraSiteTest.java, removal attempt for the first time.
public JiraSite(
URL url,
URL alternativeUrl,
Expand All @@ -407,7 +402,7 @@
boolean updateJiraIssueForAllStatus,
String groupVisibility,
String roleVisibility,
boolean useHTTPAuth,
boolean useBearerAuth,
int timeout,
int readTimeout,
int threadExecutorNumber) {
Expand All @@ -421,44 +416,10 @@
updateJiraIssueForAllStatus,
groupVisibility,
roleVisibility,
useHTTPAuth,
timeout,
readTimeout,
threadExecutorNumber);
}

// Deprecate the previous constructor but leave it in place for Java-level compatibility.
@Deprecated
public JiraSite(
URL url,
URL alternativeUrl,
StandardUsernamePasswordCredentials credentials,
boolean supportsWikiStyleComment,
boolean recordScmChanges,
String userPattern,
boolean updateJiraIssueForAllStatus,
String groupVisibility,
String roleVisibility,
boolean useHTTPAuth,
int timeout,
int readTimeout,
int threadExecutorNumber,
boolean useBearerAuth) {
this(
url,
alternativeUrl,
credentials == null ? null : credentials.getId(),
supportsWikiStyleComment,
recordScmChanges,
userPattern,
updateJiraIssueForAllStatus,
groupVisibility,
roleVisibility,
useHTTPAuth,
useBearerAuth,
timeout,
readTimeout,
threadExecutorNumber);
this.useBearerAuth = useBearerAuth;
}

static URL toURL(String url) {
Expand Down Expand Up @@ -553,10 +514,6 @@
return alternativeUrl;
}

public boolean isUseHTTPAuth() {
return useHTTPAuth;
}

public boolean isUseBearerAuth() {
return useBearerAuth;
}
Expand Down Expand Up @@ -586,11 +543,6 @@
this.alternativeUrl = toURL(alternativeUrl);
}

@DataBoundSetter
public void setUseHTTPAuth(boolean useHTTPAuth) {
this.useHTTPAuth = useHTTPAuth;
}

@DataBoundSetter
public void setUseBearerAuth(boolean useBearerAuth) {
this.useBearerAuth = useBearerAuth;
Expand Down Expand Up @@ -647,7 +599,7 @@
updateJiraIssueForAllStatus,
groupVisibility,
roleVisibility,
useHTTPAuth);
useBearerAuth);
} else {
jiraSite = new JiraSite(
url,
Expand All @@ -659,7 +611,7 @@
updateJiraIssueForAllStatus,
groupVisibility,
roleVisibility,
useHTTPAuth,
useBearerAuth,
timeout,
readTimeout,
threadExecutorNumber);
Expand Down Expand Up @@ -1156,7 +1108,7 @@

StringBuilder sb = new StringBuilder();
for (Map.Entry<String, Set<String>> entry : releaseNotes.entrySet()) {
sb.append(String.format("# %s\n", entry.getKey()));

Check warning on line 1111 in src/main/java/hudson/plugins/jira/JiraSite.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

%n should be used in place of \n to produce the platform-specific line separator.

See more on https://sonarcloud.io/project/issues?id=jenkinsci_jira-plugin&issues=AZ09t7SRoxp4O0LdMqdr&open=AZ09t7SRoxp4O0LdMqdr&pullRequest=562
for (String issue : entry.getValue()) {
sb.append(issue);
sb.append("\n");
Expand Down Expand Up @@ -1312,7 +1264,6 @@
@QueryParameter String credentialsId,
@QueryParameter String groupVisibility,
@QueryParameter String roleVisibility,
@QueryParameter boolean useHTTPAuth,
@QueryParameter String alternativeUrl,
@QueryParameter int timeout,
@QueryParameter int readTimeout,
Expand Down Expand Up @@ -1354,7 +1305,7 @@
.withCredentialsId(credentialsId)
.withGroupVisibility(groupVisibility)
.withRoleVisibility(roleVisibility)
.withUseHTTPAuth(useHTTPAuth)
.withUseBearerAuth(useBearerAuth)
.build();

if (threadExecutorNumber < 1) {
Expand Down Expand Up @@ -1416,7 +1367,7 @@
private boolean updateJiraIssueForAllStatus;
private String groupVisibility;
private String roleVisibility;
private boolean useHTTPAuth;
private boolean useBearerAuth;

public Builder withMainURL(URL mainURL) {
this.mainURL = mainURL;
Expand Down Expand Up @@ -1463,8 +1414,8 @@
return this;
}

public Builder withUseHTTPAuth(boolean useHTTPAuth) {
this.useHTTPAuth = useHTTPAuth;
public Builder withUseBearerAuth(boolean useBearerAuth) {
this.useBearerAuth = useBearerAuth;
return this;
}

Expand All @@ -1479,7 +1430,7 @@
updateJiraIssueForAllStatus,
groupVisibility,
roleVisibility,
useHTTPAuth);
useBearerAuth);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
<f:entry title="Link URL" field="alternativeUrl" description="${%site.alternativeUrl}">
<f:textbox />
</f:entry>
<f:invisibleEntry>
<f:checkbox title="${%Use HTTP authentication instead of normal login}" field="useHTTPAuth" />
</f:invisibleEntry>
<f:entry description="${%site.useBearerAuth}">
<f:checkbox title="${%Use Bearer authentication instead of Basic authentication}" field="useBearerAuth" />
</f:entry>
Expand Down Expand Up @@ -53,7 +50,7 @@
</f:entry>
<f:entry>
<f:validateButton title="${%Validate Settings}"
method="validate" with="url,credentialsId,groupVisibility,roleVisibility,useHTTPAuth,alternativeUrl,timeout,readTimeout,threadExecutorNumber,useBearerAuth" />
method="validate" with="url,credentialsId,groupVisibility,roleVisibility,alternativeUrl,timeout,readTimeout,threadExecutorNumber,useBearerAuth" />
</f:entry>
<f:entry title="">
<div align="right">
Expand Down
5 changes: 0 additions & 5 deletions src/test/java/hudson/plugins/jira/DescriptorImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ public void validateFormConnectionErrors() throws Exception {
null,
null,
null,
false,
null,
JiraSite.DEFAULT_TIMEOUT,
JiraSite.DEFAULT_READ_TIMEOUT,
Expand All @@ -149,7 +148,6 @@ public void validateFormConnectionErrors() throws Exception {
null,
null,
null,
false,
null,
-1,
JiraSite.DEFAULT_READ_TIMEOUT,
Expand All @@ -165,7 +163,6 @@ public void validateFormConnectionErrors() throws Exception {
null,
null,
null,
false,
null,
JiraSite.DEFAULT_TIMEOUT,
-1,
Expand All @@ -182,7 +179,6 @@ public void validateFormConnectionErrors() throws Exception {
null,
null,
null,
false,
null,
JiraSite.DEFAULT_TIMEOUT,
JiraSite.DEFAULT_READ_TIMEOUT,
Expand All @@ -208,7 +204,6 @@ public void validateFormConnectionOK() throws Exception {
null,
null,
null,
false,
null,
JiraSite.DEFAULT_TIMEOUT,
JiraSite.DEFAULT_READ_TIMEOUT,
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/hudson/plugins/jira/JiraSiteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private static class JiraSiteOld extends JiraSite {
boolean updateJiraIssueForAllStatus,
String groupVisibility,
String roleVisibility,
boolean useHTTPAuth) {
boolean useBearerAuth) {
super(
url,
alternativeUrl,
Expand All @@ -218,7 +218,7 @@ private static class JiraSiteOld extends JiraSite {
updateJiraIssueForAllStatus,
groupVisibility,
roleVisibility,
useHTTPAuth);
useBearerAuth);
this.userName = userName;
this.password = Secret.fromString(password);
}
Expand Down