How to change issue data with ScriptRunner groovy scripts

I made a .groovy file with which I want to change the issue summary on comment event. If the comment contains some string 'x' and that string 'x' isn't in the summary of issue, then add it to the beggining of issue summary:

Here is the code for doing this, but it doesn't seem to work, what can be the cause? I put the script in /WEB-INF/classes and in the log file isn't anything recorded.

Can I change any issue data with .groovy scripts (the file is groovy extension, but the code syntax is in JAVA)?

I made before custom listenters like this, but it was just fetching the data, it wasn't writting anything to database.

public class AddAutoIssueKeyToIssueSummary extends AbstractIssueEventListener implements IssueEventListener {

protected void addIssueKeyToIssueSummary(com.atlassian.jira.event.issue.IssueEvent event){

int stringIndex;
String issueKeyString = "HHOO-";
String temp="";

com.atlassian.jira.issue.MutableIssue eventIssue = event.getIssue();

String commentText = ComponentAccessor.getCommentManager().getComments(eventIssue).last().getBody();

if(commentText.indexOf(issueKeyString) != -1){
stringIndex = commentText.indexOf(issueKeyString);

for(int i = stringIndex + issueKeyString.length(); i < commentText.length(); ++i){

if(Character.isDigit(commentText.charAt(i)) ){
temp += commentText.charAt(i);

if(temp.length() > 0){
eventIssue.setSummary(temp + " " + eventIssue.getSummary());


// IssueEventListener implementation -----

public void issueCommented(IssueEvent e){


//whether administrators can delete this listener
public boolean isInternal()
return true;

3 answers

Did you create the custom listener in the SciptRunner ScriptListener admin panel? Did it compile without errors? Did you check the log file for errors when running this?

You might need to call updateIssue to persist the changes you've made to the MutableIssue:


Use IssueManager updateIssue call.


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption

if(temp.length() &gt; 0){
	eventIssue.setSummary(temp + " " + eventIssue.getSummary());
	ComponentAccessor.getIssueManager().updateIssue(user, eventIssue, EventDispatchOption.DO_NOT_DISPATCH, true)

Hi Andrew, thanks for the tip, I will give it a shot. Best Regards, Ivan

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


278 views 0 7
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you