Is it correct that Adaptavist wraps the Jira Java classes with groovy classes?

Hi, I am starting with groovy in Script Runner and a few things are unclear. Can I use this thread for further questions too? smile

3 answers

This widget could not be displayed.
Vasiliy Zverev Community Champion Feb 24, 2016

It is correct since groovy is extension for Java.

Ask further questions.

This widget could not be displayed.

The classes in ScriptRunner are just the original Atlassian JIRA Java classes which you can use with Groovy. So you have full access to all the methods you do on the Atlassian JIRA API. There is no special "wrapper" around them.

For example issue is just this https://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/Issue.html

For the double logging, it looks like both the root logger and the new logger you have setup are logging. In your log4j.properties can you add this to see if this solves the issue: 

log4j.additivity.com.onresolve=false

I followed the tutorial for setting up the dev environment. Everytime I log.debug something I get the message twice:

2016-02-25 10:06:54,190 http-nio-8080-exec-24 DEBUG 606x4798x1 1i3lirg 127.0.0.1 /rest/api/2/issue/10000/comment [c.o.scriptrunner.runner.ScriptRunnerImpl] My instance contains 1 users

2016-02-25 10:06:54,190 http-nio-8080-exec-24 DEBUG 606x4798x1 1i3lirg 127.0.0.1 /rest/api/2/issue/10000/comment [c.o.scriptrunner.runner.ScriptRunnerImpl] My instance contains 1 users

Any Idea why?

Hmm, strange, now I don´t get debug messages at all, even after I changed it back.

Ok, I get one debug now, which is good, but if I put log.debug in a class nothing is logged. Why is that?

That´s weird, I got an email, but your answer isn´t shown here.

I wrote a SendEmail class, in a send method I´ll do log.debug "something" and that debug message is not shown in the log. If I do log.debug in the class calling script I can do log.debug, but not in the imported class.

Hi Marc, add the following to your class:

@groovy.util.logging.Log4j
class SendEmail {
	public void send() {
		log.debug("hello")
	}
}

Hmm, still nothing, here the class:

http://pastebin.com/dmLEx29G

Can you set the logging level to debug in the script console by doing: https://scriptrunner.adaptavist.com/latest/jira/getting-help.html#_support_requests

Then run your script.

Or do log.warn instead.

Hmm, still no debug in classes.

Is that a one time thing or should I put it in my script too?

You need to change the package the script is under to "com.onresolve" or do:

@Log4j(category = "com.onresolve.somepackage")
class SendEmail {
    public void send() {
        log.debug("hello")
    }
}

Its probably easier to use a higher logging level like log.warn.

To sum this up, we solved it by adding:

log4j.logger.library = DEBUG, console, filelog

log4j.additivity.library = false

to the log4j.properties file

This widget could not be displayed.

Ok, next question:

The classes I fetch from ComponentAccessor, is that always a new instance or an instance that JIRA already uses at that moment?

I want to extend the CommentManager, is that doable by changing the factory or do I have to instatiate it with all it´s dependencies?

 

Can you ask a new question please, answering a question with a new question makes it hard for people to use this as a resource.

Aw, Jamie! But I love using tools where I can squish all the information is in a single long running thread. Email just roolz ;-)

Sure, no problem :=)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

510 views 3 18
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