Under the covers, the code you write with Scriptrunner in groovy consist of Java code.
And in groovy just as in java, you can only interact with object classes that have been imported into the current context.
A class must already exist and be available within the class loader context before it can be explicitly imported into a script or another class. So that means that just about any class available in Jira will be available for import.
Generally, you will learn over time which classes are useful. But you can also consult the javadocs for your version: E.g. https://docs.atlassian.com/software/jira/docs/api/8.20.13/index.html to know what's available.
By default, classes that are provided by plugins won't be available. But Scriptrunner ships with a special "WithPlugin" class that let us get access to classes for a given plugin if you know the plugin key.
Also, it's possible to import classes not available in the Jira environment by using @grab statements. This will download the .jar files associated with the packages you grab from a public maven repository and store them locally.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Saqib Dar a small example, just explain base on concept of @Peter-Dave Sheehan , hope it help you
Example for @grab
@Grab(group='org.apache.directory', module='groovyldap', version='0.1-SNAPSHOT')
import org.apache.directory.groovyldap.util.Util
def properties = Util.getProperties()
for (def key in properties.keySet()){
log.info("Key ---> " + key)
}
import com.atlassian.jira.component.ComponentAccessor
def field = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_15923")
log.info(field.getName())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.