Remote Debug Groovy in IntelliJ

Angelos January 2, 2014

Hi,

We are running a development version of JIRA in a remote server and I am trying to debug from my workstation.

In the documentation it says

Put a breakpoint on the last line. Copy the script path and run the script in the groovy admin panel. The breakpoint will be hit.

But I am not sure about how I can point Script Runner to the path of my script, assuming that's what is required.

Is it possible to debug on a remote server at all?

1 answer

1 accepted

1 vote
Answer accepted
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.
January 2, 2014

The IDE knows what file to open when the breakpoint is hit from the name of the class, and presumably some debug info added to the class at compile time.

However in the current version of script runner (this will change in the next major release), for scripts, you will need to wrap it in a class.

Eg:

class Foo() {
def main() {...}
}

new Foo().main()

this is a bit of a pain.

I don't think there is any difference whether you are debugging remotely or locally.

Angelos January 2, 2014

Thanks for your response Jamie.

I already have my script wrapped in a class in the same way as in your example.

However when you say

Copy the script path and run the script in the groovy admin panel.

Is the "groovy admin panel" the same as Script Runner in the Jira Addon's page? I am a bit confused with the terminology here.

If it makes any difference, my script will eventually run as a service.

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.
January 2, 2014

I strongly advise you to run jira on your own machine, and not worry about remote debugging. If you need a copy of your production database to test then get one...

When you are finished you can deploy to production.

If you later have problems then clone the env to your dev machine. If you remote debug it will suspend the jvm when it hits a breakpoint, and freeze jira for anyone using it.

Angelos January 2, 2014

Perfect! It now makes complete sense.

I am trying to setup jira to start with JPDA on windows which I didn't have much luck so far, but I will get there.

Thank you

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.
January 2, 2014

Yeah, it's the same. The plugin was renamed to script runner some time back.

Running the script as a file from Admin -> Script Console is a good way to test and develop the service.

The file has to be local to the jira server - you can't point it at a file on your machine. Scp it to the machine and edit it in winscp or something...

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.
January 2, 2014

No problem... ask if you have any questions on debugging. There is some basic info here: https://jamieechlin.atlassian.net/wiki/display/GRV/Script+Runner;jsessionid=BFE83D471B6DB72BDE06F5E31B22663D#ScriptRunner-DebuggingandCodingwithIDEA- the pictures are years out of date but the principal is the same.

Angelos January 2, 2014

Just to confirm, it's all working nicely locally. I had to change the port from 8000 to 8001 as it was in use by something else.

In addition it appeared that breakpoints only worked inside the class and not in the code instantiating and executing the object's methods.

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.
January 2, 2014

Yes, in this version of the plugin breakpoints in scripts don't work, but they do in your own classes or classes you define in scripts.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events