Community moderators have prevented the ability to post new answers.
It certainly could create problems, though which ones are likely to manifest is hard to say. I believe the ProjectManager.getNextId method is transactional, so you shouldn't see problems where the same ID gets taken by multiple processes. I'm not 100% certain on that, though. If I'm right, and the script fails for some reason after grabbing the ID, you could potentially get gaps in your issue ID sequence.
Hard-coding the Issue Type Id and Status ID might lead to problems if you do some status re-naming/re-organizing, but then again, so could looking them up by their name.
I can't think of any other issues off the top of my head, though the more you run the script, the more likely you are to run into problems if they're there, right?
To quote a wise person, "The fact that this is not available in any @PublicApi should probably be enough to put you off, unless you have a taste for adventure." If it works, and you don't mind dealing with messes (such as broken issue key referals across multiple moves), and you don't need to lean too hard on it (i.e., if it stops working, you're not in trouble), then you're proooobably fine?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jonny,
Thank you for your reply. Before you commented, I manage to write the following script who does the move as expected:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.ModifiedValue import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.IssueManager import com.atlassian.jira.issue.IssueFactory import com.atlassian.jira.issue.MutableIssue; import com.atlassian.jira.issue.search.SearchProvider import com.atlassian.jira.issue.util.DefaultIssueChangeHolder import com.atlassian.jira.jql.parser.JqlQueryParser import com.atlassian.jira.web.bean.PagerFilter import com.atlassian.jira.issue.link.IssueLinkManager import com.atlassian.jira.issue.link.IssueLinkType import com.atlassian.jira.issue.link.IssueLinkTypeManager import com.atlassian.jira.issue.link.DefaultIssueLinkManager import com.atlassian.jira.event.type.EventDispatchOption import com.atlassian.jira.event.issue.IssueEvent import com.atlassian.jira.issue.util.IssueChangeHolder import com.atlassian.jira.event.type.EventDispatchOption import com.atlassian.jira.event.issue.IssueEvent IssueEvent event; def customFieldManager = ComponentAccessor.getCustomFieldManager() def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() def issueFactory =ComponentAccessor.getIssueFactory() MutableIssue issue = ComponentAccessor.getIssueManager().getIssueObject("IS-3"); def projectManager = ComponentAccessor.getProjectManager(); def targetProject = projectManager.getProjectObjByKey("RB"); def nextId = projectManager.getNextId(targetProject); issue.setProjectObject(targetProject); issue.setNumber(nextId); issue.setIssueTypeId('10001'); issue.setStatusId('10002'); issue.store(); def currentUser = ComponentAccessor.jiraAuthenticationContext?.getLoggedInUser() ComponentAccessor.getIssueManager().updateIssue(currentUser, issue, EventDispatchOption.ISSUE_UPDATED, false);
Wanted to know if you think it is OK or going to create many problems?
Thanks,
Noga.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This has been a difficult thing to do in JIRA for a while, almost deliberately so. See https://answers.atlassian.com/questions/150179 and https://jira.atlassian.com/browse/JRA-16494. Generally, Atlassian recommend you don't move issues around for any reason other than getting them to the right project after miscreation. If you're doing it often enough that you need to automate it (beyond using the Bulk Move option in the issue navigator), then you may be setting yourself up for hurt down the road.
Jamie's old gist at https://gist.github.com/jamieechlin/5213550 might be adaptable to the JIRA 7.1 context, but even if you ported it, the script is likely to break across upgrades, as Atlassian is deliberately keeping the the move operation out of the public API.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.