Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,990
Community Members
 
Community Events
176
Community Groups

Using your own scripts

Good afternoon. Help solve the problem using the generated scripts. We have an endpoint where I want to use a script from the Script Editor. But I get an error - The script could not be compiled:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script761.groovy: 17: unable to resolve class Generator

Снимок экрана от 2022-02-18 15-37-37.pngСнимок экрана от 2022-02-18 15-36-57.pngСнимок экрана от 2022-02-18 15-36-15.png

2 answers

1 accepted

0 votes
Answer accepted

If you want to import a class into another script, the script file has to match the class name.

So try to rename update.groovy to Generator.groovy

Then you will be able to 

import sidebar.Generator
Generator gen = new Generator()
gen.collectData(...)

I see that your collectData method is static, this means you don't need to instantiate the class first:

import sidebar.Generator
Generator.collectData(...)

Thanks. It works for normal classes. What about nested classes? I have classes in my Generator script and I want to call one of the nested class methods. Generator.InnerClass.method() not working

I don't think it's possible to access a nested class that is nested inside a script.

The nested class would only be available from inside the script itself.

So if you want your nested class to be available to other scripts, then it must be nested inside a proper groovy glass.

Hi boris_samoylov,

Your filename should be the same as your class name. So, you can update the filename to Generator.groovy and update the import to sidebar.Generator and it should work now.

I hope this helps!

Cheers,
Helmy

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events