Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Link Issue mentioned in Jira comment with Scriptrunner Listener

Hey All,

I'm looking for some scripting help with a Scriptrunner Listener script. I'm in need of a full listener script that will create an issue link when an issue is mentioned in the comments of the current issue. 

I found another article but it was a snippet of the script and some of the groovy wasn't valid. 

Any help and/or guidance would be greatly appreciated.


1 answer

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 07, 2023 • edited

Hi @Norm Moore

For your requirement, you can try something like this:-

import com.adaptavist.hapi.jira.issues.Issues
import com.atlassian.jira.issue.MutableIssue
import org.apache.commons.lang3.StringUtils

def issue = event.issue as MutableIssue
def lastComment = issue.comments.last()
def resultBuilder = new StringBuilder()

if (lastComment.body.contains("${issue.projectObject.key}-")) {
def filter1 = issue.projectObject.key.charAt(0)
def filter2 = StringUtils.substringAfter(lastComment.body,"${filter1}").split("\\s+")

def linkedIssue = Issues.getByKey(resultBuilder.toString())'blocks', linkedIssue)

Please note that the sample code above is not 100% exact to your environment. Hence, you will need to make the required modifications.

Below is a screenshot of the Listener Configuration:-


For the sample code above to work, please ensure you have updated your ScriptRunner plugin to the latest release, i.e. 8.0.0.

With the latest release, you will be able to make use of ScriptRunner's HAPI feature, which helps to simplify the code.

Below are a couple of test screenshots for your reference:-

1. First, I added a comment and included an issue key. In the sample below, I have entered MOCK-2 for the issue key. I then click the add button.


2. As expected, the MOCK-2 issue is added to the issue link.


3. I then repeat the same test with issue MOCK-11.image3.png


4. As expected, the MOCK-11 issue is added to the issue link.image4.png

Note: Please ensure that you refresh the page after adding the comment to display the linked issue.

I hope this helps to answer your question. :-)

Thank you and Kind regards,


@Ram Kumar Aravindakshan _Adaptavist_ 

Thank you very much! It works like a charm. 

I appreciate all the help and effort in the script. 


Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events