| Jenkins: v2.44 JIRA plugin: v2.3 In v2.3 (currently the latest) of the JIRA plugin, I believe there is a bug in JiraProjectProperty. The issue is in the setSites() method here: https://github.com/jenkinsci/jira-plugin/blob/7600eb9c12559119d9599cdeaa088862a5c6dfc3/src/main/java/hudson/plugins/jira/JiraProjectProperty.java#L94-L96 The "setSites" method is currently written as follows:
public void setSites(JiraSite site) {
sites.add(site);
}
Instead, I believe it should be:
public void setSites(JiraSite site) {
sites.clear()
sites.add(site);
}
I first noticed this tonight when attempting to configure the JIRA plugin with a Groovy script. Every time I ran the Groovy script, a brand new JIRA site would appear in Jenkins – one, then two, then three, then four, etc. The Groovy script was calling "setSites" every time with just one single site, but the list kept growing. Here's the Groovy script I was running, which will demonstrate this behavior:
import hudson.plugins.jira.*
import jenkins.model.*
import java.net.URL;
URL url = new URL("http://foo.atlassian.net/")
URL alternativeUrl = null
String userName = "he...@foo.com"
String password = "my-password-here"
boolean supportsWikiStyleComment = true
boolean recordScmChanges = true
String userIssuePattern = ""
boolean updateJiraIssueForAllBuildStatus = true
String groupVisibility = ""
String roleVisibility = ""
boolean useHTTPAuth = false
def site = new JiraSite(url, alternativeUrl, userName, password, supportsWikiStyleComment, recordScmChanges, userIssuePattern, updateJiraIssueForAllBuildStatus, groupVisibility, roleVisibility, useHTTPAuth)
def instance = Jenkins.getInstance()
jiraPlugin = instance.getDescriptorByType(hudson.plugins.jira.JiraProjectProperty.DescriptorImpl)
jiraPlugin.setSites(site)
Actual Behavior: Executing this script "n" times results in "n" copies of the JIRA site in the Jenkins instance.  Expected Behavior: Executing this script "n" times results in 1 copy of your JIRA site in your Jenkins instance. |