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

e.AbstractIssueEventListener

 @ line 3, column 1.

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

   ^

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

e.IssueEvent

 @ line 4, column 1.

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


How can I make it work?

1 answer

1 accepted

1 votes

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,087 views 13 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot