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

Holger Buhr February 24, 2016

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

1 vote
adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 24, 2016

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
Holger Buhr February 25, 2016

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?

Holger Buhr February 25, 2016

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

Holger Buhr February 25, 2016

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

Holger Buhr February 25, 2016

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.

adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 25, 2016

Hi Marc, add the following to your class:

@groovy.util.logging.Log4j
class SendEmail {
	public void send() {
		log.debug("hello")
	}
}
Holger Buhr February 25, 2016

Hmm, still nothing, here the class:

http://pastebin.com/dmLEx29G

adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 25, 2016

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.

Holger Buhr February 25, 2016

Hmm, still no debug in classes.

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

adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 25, 2016

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.

Holger Buhr February 25, 2016

ok, thank you smile

Holger Buhr March 3, 2016

To sum this up, we solved it by adding:

log4j.logger.library = DEBUG, console, filelog

log4j.additivity.library = false

to the log4j.properties file

1 vote
Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 24, 2016

It is correct since groovy is extension for Java.

Ask further questions.

Holger Buhr February 24, 2016

Thank you!

0 votes
Holger Buhr February 25, 2016

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?

 

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 25, 2016

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.

MattS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 25, 2016

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

Holger Buhr February 25, 2016

Sure, no problem :=)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events