Our teams will paste several Jira tickets link in description field to indicate related changes. But we found the input tickets could not be linked without add the links manually one by one. Is it possible to automatically find the links included in description and configure them automatically as issue links?
This is possible by using ScriptRunner, I will provide the Pseudo code.
Now, there are nuances here that needs to be resolved first.
By answering the questions above you should narrow down the requirements accordingly.
How could I use ScriptRunner in my Jira projects? And how could I configure it?
Thank you very much.
Best regards,
Catherine
@[deleted],
Give me few hours, I will write the script for you.
Also keep in mind you need to install the ScriptRunner add-on in your Jira instance.
Hi @[deleted],
Add this script to the ScriptRunner Script Listener.
Specify the Project where the script will trigger and make sure that the event is Issue Updated.
import com.atlassian.jira.component.ComponentAccessordef ALLOWED_ISSUETYPES = ['Bug', 'Story', 'Task']def LINKID = 10001 // Clone link type, Change this if you want different link typedef SEQUENCE = 10001 // Don't change the default valuedef PROJECT_KEY = 'DSWCPA'def PATTERN = /$PROJECT_KEY-[0-9]/if(!issue.getIssueType().getName() in ALLOWED_ISSUETYPES){ return}if(event?.getChangeLog()?.getRelated('ChildChangeItem').find {it.field == 'description'}){ def matcher = issue.description =~ PATTERN matcher.find() if(matcher.size()){ def destIssue def applicationUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() matcher.each{ try{ destIssue = ComponentAccessor.getIssueManager().getIssueByCurrentKey(it) ComponentAccessor.getIssueLinkManager().createIssueLink(issue.id, destIssue.id, LINKID, SEQUENCE, applicationUser) }catch(Exception ex){ log.debug("Error linking the issue.") } } }}
It looks like you're new here. Sign in or register to get started.