Hi,
My situation is this : I have one project named Opportunities (OP) where we create Epics for unapproved requests. When we analyse these epics, we create stories for the different tasks that would needed to be done if this request was approved. These "issues in Epic" are created in different projects. If the request is approved, then we create a new Epic in an other project (LM) and we link both Epics together. I want to change the Epic link for all the stories from the Epic in OP project to the Epic in LM project.
Is there a way to automate this with ScriptRunner in a post function? I looked around for an answer but can't seem to find it.
Any suggestions?
Thanks
This should be possible. If you first get all the linked issues of the parent epic you should be able to loop through them, delete the old link and create a new one. Take a look at IssueLinkManager: https://docs.atlassian.com/software/jira/docs/api/8.9.1/com/atlassian/jira/issue/link/IssueLinkManager.html
Hope this helps :)
Hi, yes it did help a bit. I'm new with Jira APIs so I still have some problems with writing my scripts and my code is not working for now. I tried something like this, but the removeLink doesn't seem to work. And I can't use the createIssueLink method, an error always comes up.
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.Issueimport com.atlassian.jira.issue.IssueManagerimport com.atlassian.jira.issue.link.IssueLinkimport com.atlassian.jira.security.roles.ProjectRoleManagerimport com.atlassian.jira.issue.link.DefaultIssueLinkManager
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
boolean filterIssueTypes = true List<String> issueTypes = ["Epic"] boolean filterLinkedIssueTypes = true List<String> linkedIssueTypes = ["Epic"] boolean filterLinkTypes = false
if (issue.issueType.name in issueTypes || !filterIssueTypes) { def issueLinkManager = ComponentAccessor.issueLinkManager issueLinkManager.getOutwardLinks(issue.id).each { IssueLink issueLink -> def destinationIssue = issueLink.destinationObject if (destinationIssue.issueType.name in linkedIssueTypes || !filterLinkedIssueTypes) { def epicLM = destinationIssue.toString() boolean filterLinkedIssueTypes2 = true List<String> linkedIssueTypes2 = ["Story"]
if (issue.issueType.name in issueTypes || !filterIssueTypes) { issueLinkManager.getOutwardLinks(issue.id).each { IssueLink issueLink2 -> def destinationIssue2 = issueLink2.destinationObject if (destinationIssue2.issueType.name in linkedIssueTypes2 || !filterLinkedIssueTypes) { issueLinkManager.removeIssueLinks(destinationIssue2, user) } } } } }}
Also, with the issueLinkManager, it seems like the only types of links that I can create are : is duplicated by, is related to, etc. I don't think I can create a epicLink type of link. I found an EpicLinkManager class online :
https://docs.atlassian.com/jira-software/6.3.9.2/com/atlassian/greenhopper/manager/issuelink/EpicLinkManager.html#getIssuesInEpic(com.atlassian.jira.issue.Issue)
but it's for Jira server 6.3.9 and I'm using Jira 8.7.1 and I can't even call it. I tried it like this, but it gives me an error
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.Issueimport com.atlassian.jira.issue.IssueManagerimport com.atlassian.jira.issue.link.IssueLinkimport com.atlassian.jira.security.roles.ProjectRoleManagerimport com.atlassian.jira.issue.link.DefaultIssueLinkManagerimport com.atlassian.fugue.Option
if(issue.issueType.name=="Epic") { def epicOP = (Option)Option.option(issue) def epicLinkManagerImpl = getClass("epicLinkManagerImpl"); issuesInEpic = epicLinkManagerImpl.getIssuesInEpic(issue) return issuesInEpic.toString()
}
As you can see, I'm a bit clueless here, so if you have any suggestion for me to try it would be really helpful.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.