Forums

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

Creating new classes in scripts that start scriptrunner or mygroovy

Alexander Raymukanov August 9, 2020

Am I right that it is impossible to create classes in script body?

Like below. sorry if there are grammar mistakes in code, I am newbie

Class newEvent (AbstractVersionEvent event){

def version = event.version
def versionName = version.name
logger.info "version: "+versionName+"\n"
def project = version.getProject()
logger.info "project id: "+project.id+"\n"
def projectCategory = project.getProjectCategory()
}
Class newUpdateEvent (VersionUpdatedEvent event) extends newEvent{
def oldVersion=event.originalVersion
def oldVersionName=oldVersion.name
}

 

1 answer

0 votes
Italo Qualisoni [e-Core]
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.
August 9, 2020

Hi @Alexander Raymukanov ,

Can you describe what are you trying to achieve with Scriptrunner? What business case are you looking for to resolve?

Alexander Raymukanov August 9, 2020

I try to write my own version synchronizer based on AbstractVersionEvent. 

And I want to create new class, and object of this class will store all information about event that  I need. If event will be a VersionUpdatedEvent than another extended class with additional fields will be used. 

When I tried to write new class construction in script it don't see my class. And my question is it possible to construct new class in script body? Or the only way to create separate file with new class and place it on the server locally and implement import header for it?

Italo Qualisoni [e-Core]
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.
August 9, 2020

And why don't you just create a script listener based on VersionUpdatedEvent  with your custom logic (example https://scriptrunner.adaptavist.com/latest/jira/listeners.html#_custom_listener_example)? 

 

It seems that you can create your custom listener (see below doc) but I think this can be over-complicated to maintain;

https://scriptrunner.adaptavist.com/latest/jira/listeners.html#__heritage_custom_listeners

Suggest an answer

Log in or Sign up to answer