Starting With Groovy - No Output in Console

I'm a programmer who is just getting started working with groovy in Jira in order to automate some tasks.

I'm trying to write a custom listener script using the inline editor in Jira, but haven't gotten past trying to get a Hello World program to work.

I don't know if the script is running, and can't see any output, and I really need some help with figuring out how to debug the script, preferably through outputs to some kind of console (or even just by reading the Jira logs if necessary), just so that I can actually start trying to learn how to use this tool.

I'm working with the information HERE as a general guideline to start learning to work with the inline editor.

For a little more context, you can see another related question that I asked HERE.

I've set the debug level to DEBUG for the event which I'm attaching the listener, as shown in this screenshot, based on the information found HERE: 

Listener.PNGNote that I've also tried

log.debug("Hello")

As you can see, in the 'Result' tab at the bottom of the screen, there is nothing of interest. The 'Logs' tab is also empty, and the 'Timing' tab just says 'Elapsed: 0 ms CPU time: 0 ms', so it seems like nothing if happening.

If I check the log on the server (in the file catalina.2017-10-13.txt), I see the following output:

13-Oct-2017 07:01:50.942 WARNING [http-nio-8080-exec-6] com.sun.jersey.spi.container.servlet.WebComponent.filterFormParameters A servlet request, to the URI http://somevmserver:8080/rest/scriptrunner-jira/latest/listeners/com.onresolve.scriptrunner.canned.jira.workflow.listeners.CustomListener/params, contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.
13-Oct-2017 07:02:26.740 WARNING [http-nio-8080-exec-12] com.sun.jersey.spi.container.servlet.WebComponent.filterFormParameters A servlet request, to the URI http://somevmserver:8080/rest/scriptrunner/latest/canned/com.onresolve.scriptrunner.canned.common.StaticCompilationChecker, contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.
13-Oct-2017 07:02:26.974 WARNING [http-nio-8080-exec-1] com.sun.jersey.spi.container.servlet.WebComponent.filterFormParameters A servlet request, to the URI http://somevmserver:8080/rest/scriptrunner-jira/latest/listeners/com.onresolve.scriptrunner.canned.jira.workflow.listeners.CustomListener/preview, contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.

 

This output doesn't mean a whole lot to me, but it seems apparent that it's being populated as a result of trying to preview the script.

I'm not getting any errors in the inline editor, and it's really simple code, so I don't think it's that.

The only other information I can include that I think is pertinent is that this is a test instance of Jira cloned from our production environment, and its base URL is still set to the URL of the prod environment. Not sure if that has any bearing, but I'm not really a Jira admin, just the programmer tasked with doing this, so I don't want to go fiddling around where I don't need to.

Thanks!

1 answer

0 votes

Hi Jake.

Are you sure the listener is being triggered?

Can you see in the history that it has been triggered by an event?

Cheers

Dyelamos

Hi Daniel, 

I haven't even gotten as far as actually adding the listener. I am literally just hitting the preview button. 

I'm pretty sure that hitting preview is causing something to happen, as it adds one of the above mentioned entries to the log every time I try it, but I see no output in the console. 

At the moment, if I could just get a hello world to work, that would allow me to figure out how to get my actual code to work through trial and error.

Am I going about this wrong or operating under some false assumptions? I assume that running the following script:

log.debug "Hello"

Should print "Hello" to the log in the editor? Is this not accurate?

No, preview will not execute the script, it will only make sure that it would have no problems running, for example, parameter checking.

Cheers!

DYelamos

Ok, I've added the listener, still with just the code

log.debug "hello" 

The listener is set to run for OnUpdated, and I updated an issue to test.

I'm not seeing that output in any of the logs. Could you describe how to check the history to see if the listener has been triggered?

I found the history, and it's saying that there were no failures in the last X executions. So I guess it's being triggered. 

However, I'm still not seeing any output anywhere. Still just a ton of warnings in the log. 

I even tried

log.info("Some Stuff")


But I'm still getting nothing. Any thoughts?

Here you can learn how to check your logs.

https://confluence.atlassian.com/jira063/where-are-the-application-server-logs-683542381.html

You should check that file for those debug statements. They if they are getting triggered like you mentioned, in the history, they should be there.

Cheers

Dyelamos

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 31, 2018 in Marketplace Apps

Marketplace Spotlight: Zephyr

Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...

346 views 0 1
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