How to import com.atlassian.jira...

I'm trying to create a custom groovy listener.
First of all, I created groovy class:

package com.custom

import com.atlassian.jira.event.issue.AbstractIssueEventListener;
import com.atlassian.jira.event.issue.IssueEvent;
class MyListener extends AbstractIssueEventListener {
    void issueUpdated(IssueEvent event) {
        // code

And now, I'm trying to compile it with groovyc. I got these errors:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

MyListener.groovy: 3: unable to resolve class com.atlassian.jira.event.issu


 @ line 3, column 1.

   import com.atlassian.jira.event.issue.AbstractIssueEventListener


MyListener.groovy: 4: unable to resolve class com.atlassian.jira.event.issu


 @ line 4, column 1.

   import com.atlassian.jira.event.issue.IssueEvent

How can I make it work?

1 answer

1 accepted

You'll need to set a massive classpath, but you should not need to compile it. Just point the "custom listener" at the .groovy file, and it will handle compiling.

thank you Jamie for a quick answer. But how can I point the custom listener at the groovy file if in jira, as I see, I need .class file? Or what I did wrong to make a custom listener? I put .groovy file ...WEB-INF/classes/com/custom/MyListener.groovy. And inscript runner in creating a custom listener in field: name of groovy class I cannot find it. And in jira administration where listeners, I cannot find it too.

What version of jira and the plugin are you using?

jira 6.3.8, script runner plugin 3.0.7.

I created empty file hello.class in /WEB-INF/classes/com/custom/ and then I can see him as a listener, so how can I compile my first MyListener.groovy in MyListener.class? I tried groovyc and nothing good, as you see. Set a massive classpath isn't good solution. Now, I'm trying to do it with Intellij, but I met a problem: idea doesn't understand imports with com.atlassian.jira. ... And I dont know how to add it. Can you help me please, Jamie?

but you said I dont need to compile .groovy, what should I do to make it visible in "groovy class name" field?

Use Custom Listener, and you put the .groovy file under one of your script roots, eg <jira_home>/scripts, in the correct directory according to its package.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,721 views 17 21
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