Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Unable to resolve class in Scriptrunner import clause

Hi.

I'm writing a Scriptrunner script to manage Bamboo build plans upon Jira issue status change. For that I need to get an assigned to the issue branch. I do it that way:

import com.atlassian.jira.plugin.devstatus.impl.DefaultDevStatusSummaryService

def ccm = ComponentAccessor.getComponentClassManager()
def service = ccm.newInstance("com.atlassian.jira.plugin.devstatus.impl.DefaultDevStatusSummaryService")
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

//def issue = ComponentAccessor.getIssueManager().getIssueObject("CDI-5")
def details = service.getDetailData(issue.id, "stash", "pullrequest", currentUser).right().get().getDetail()

When I have first line with "import" commented out it works fine but syntax checker in the script editor underlines last line with "service.getDetailData" with error that "getDetailData" is unknown for "java.lang.Object", which is understandable. But if I uncomment first line I get a compiler error "unable to resolve class com.atlassian.jira.plugin.devstatus.impl.DevStatusSummaryService". Why is that? 

If I comment out first line and check type of the "service" variable I get:

class com.atlassian.jira.plugin.devstatus.impl.DefaultDevStatusSummaryService

 

1 answer

0 votes
Danyal Iqbal Community Leader Apr 23, 2018

this is not allowed .

How do you trigger the execution?

Add the directory to your script roots-https://scriptrunner.adaptavist.com/latest/jira/#_script_roots

Try the import with "@WithPlugin" directive e.g

@PluginModule
AllPublicStructureComponents structureComponents

// Specify that classes from this plugin should be available to this script
@WithPlugin("com.atlassian.jira.plugin.devstatus.impl.DefaultDevStatusSummaryService")

What is not allowed? Using plugins in script?

So far I don't trigger the execution but start the script manually. In the future I'm going to run it as a post-function in workflow status transition.

Try the import with "@WithPlugin" directive e.g

 I tried. The result was a bit different but the error was same:

unable to resolve class com.atlassian.jira.plugin.devstatus.impl.DevStatusSummaryService @ line 4, column 1. @WithPlugin("com.atlassian.jira.plugin.devstatus.impl.DefaultDevStatusSummaryService")

Danyal Iqbal Community Leader Apr 24, 2018

@WithPlugin("enter plugin.key here")

Find the key here: Manage addons>select plugin>addon key.

This annotations only work when running a script that is under a script root (the script directory is teh script root by default. place your script there)…​ not a script outside a script root, nor code pasted into the console.

What is not allowed?

Your approach to import another plugin in your script.

Yeah, you're right about @WithPlugin annotation.

Still if I comment "import" clause out I can run the script from script console (it accesses branches and pull requests of the issue). So it seems it's possible to access plugins from console scripts. How can it be?

Danyal Iqbal Community Leader Apr 24, 2018

+1 for

How can it be?

You should create a support request to report unexpected behaviour. They should be able to explain it away. I am also curious.

Ok, thanks. 

Created a request to Adaptavist https://productsupport.adaptavist.com/servicedesk/customer/portal/2/SRJSUP-4549

Let's see what they say

Actually even when running from file it gives same error:

2018-04-25 16:04:09,172 WARN [common.UserScriptEndpoint]: Script console script failed: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: file:/var/atlassian/application-data/jira/scripts/test.groovy: 4: unable to resolve class com.atlassian.jira.plugin.devstatus.impl.DefaultDevStatusSummaryService @ line 4, column 1. @WithPlugin("com.atlassian.jira.plugins.jira-development-integration-plugin") ^ 1 error

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

109 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you