Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scriptrunner/Groovy strongly typing bound variables

Daniel Garcia
Contributor
April 22, 2020

This is more of a groovy question but within the context of scriptrunner.

When you create a script there are a number of variables bound to the script but the IDE (IntelliJ) doesn't know about them. e.g. if I create a script field, "issue" is a bound variable

intellij-1.PNG

As you can see, "issue" has a dotted line and there is no auto-completion

One way to remedy this is to use "as Issue" everywhere

intellij-2.PNG

but that can get cumbersome

InteliJ does allow you to define Dynamic Properties for scripts but the interface is all point and click, one variable at a time, one script at a time. It would be so much simpler if there was an annotation or something.

I dug through the IntelliJ code looking for a way to extend the groovy plugin so I could apply these to a namespace but didn't have any luck. :( Grrrr, I spent too much time looking at that.

The best I could come up with was something like this

import com.atlassian.jira.issue.Issue

Issue issue = binding.variables.issue

String projectName = issue.projectObject.name

Will this cause any issues with groovy due to 2 variables with the same name?

Is there a better way?

 

 

 

 

 

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.3.2
TAGS
AUG Leaders

Atlassian Community Events