-
Bug
-
Resolution: Fixed
-
Major
-
None
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:
It is currently written as follows:
public void setSites(JiraSite site) { sites.add(site); }
The issue specifically is that the setSites() is behaving more like an "add site" command. This can result in duplicate JiraSite objects ending up in your config.
Steps to Reproduce:
I first noticed this tonight when attempting to configure the JIRA plugin with a Groovy script. In the Groovy script (see below), I create a JiraSite object, then save it to the instance with "setSites()".
Every time I run the Groovy script, however, an additional entry for my single JIRA site is added to my instance.
import hudson.plugins.jira.* import jenkins.model.* import java.net.URL // create JiraSite object URL url = new URL("http://foo.atlassian.net/") URL alternativeUrl = null String userName = "hello@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) // call setSites() to save the JiraSite def instance = Jenkins.getInstance() jiraPlugin = instance.getDescriptorByType(hudson.plugins.jira.JiraProjectProperty.DescriptorImpl) jiraPlugin.setSites(site) jiraPlugin.save()
Expected Behavior:
- Calling setSites() should behave like a true "set" operation.
- You should be able to call setSites() as many times as you want, but if you're only ever passing in one JiraSite, then you should end up with one JiraSite in your instance.
Actual Behavior:
- Calling setSites() is currently behaving like an "add" operation.
- If you run this script 10 times, but you're only ever passing in one JiraSite, you'll end up with 10 duplicate JIRA projects configured.