Is it possible to use Scriptrunner to use a jql search to find all issues with the same fix version of the "parent" and link those issues to said parent?
Yes, you can do almost everything with groovy scripts. When do you want to do this "linking"? Manually and just once to init your data? Or when you're updating fix version on some issue?
I'm looking to have it linked to the primary issue whenever an issue from a specific project has that fix version added to one of its issues. I'm assuming that I'd use a listener? Maybe incorporating jql somehow?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, exactly, you will use listener which reacts to ISSUE_UPDATED. Then you need to write script which will
parentIssue.getFixVersions()
UserManager userManager = ComponentAccessor.getUserManager()
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager()
Collection<Version> parentIssueVersions = parentIssue.getFixVersions()
String parentIssueVersionsAsString = parentIssue.getFixVersions().collect{ it.getName() }.join(",")
String jqlSearch = 'fixVersion in (' + parentIssueVersionsAsString + ')'
def serviceUser = userManager.getUserByName("service") // you need some user which has permission to search and view issues
//setup search
def parseResult = searchService.parseQuery(serviceUser, jqlSearch)
def issuesWithFixVersion = []
if (parseResult.isValid()) {
def searchResult = searchService.search(serviceUser, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
issuesWithFixVersion = searchResult.issues
}
Long linkTypeId = 1L // you need link type id
issuesWithFixVersion.each { issueLinkManager.createIssueLink(parentIssue.id, it.id, linkTypeId, Long.valueOf(1), serviceUser ) }
These are just snippets of code but I hope it will help you. Feel free to post more questions here, of course.
Maybe my question... what do you mean by "parent" issue? Is it special type of issue linked to other issue with specific link type?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.