Access development information from groovy script-runner

Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 13, 2017

Hi,

 

I had Jira 6.2, tried the solution from this thread:

https://community.atlassian.com/t5/Answers-Developer-Questions/Access-development-information-from-groovy-script-runner-in/qaq-p/517778

 

And it worked for me.

But now we upgraded our jira from 6.2 to 7.3.7

And this code not working anymore.

Couldn't find any documentation for this.

 

While having this code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.plugin.devstatus.api.DevStatusSummaryService
import com.atlassian.jira.plugin.devstatus.rest.DetailBean
import com.atlassian.jira.user.ApplicationUser
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

@WithPlugin("com.atlassian.jira.plugins.jira-development-integration-plugin")
DevStatusSummaryService devStatusSummaryService = ComponentAccessor.getOSGiComponentInstanceOfType(DevStatusSummaryService.class)

ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getUser()

DetailBean pullRequestData = devStatusSummaryService.getDetailData(issue.id, "stash", "pullrequest", currentUser).get()

return pullRequestData as String

 

I have error on:

devStatusSummaryService.getDetailData(issue.id, "stash", "pullrequest", currentUser).get()

The error says:

[Static type checking] - Cannot find matching method

io.atlassian.fugue.Either#get(). Please check if the declared type is right and if the method exist.

Possible solutions: grep(), grep(java.lang.Object), getAt(java.lang.String), wait(), any(), wait(long), @line 12, column 30.

 

Can anyone help to dinf a solution?

I need to recieve the development panel data as i used to get from above code in Jira 6.2

 

Thanks,

Nir

 

2 answers

0 votes
Alexey Belostotskiy March 20, 2019

Here's a way to get DevStatusSummaryService in Jira versions where it's not exported from plugin.

Keep in mind that you're accessing internal component, but IMO it's still better than creating your own instance of that component every time your script is executed (which some people are doing).

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.plugin.devstatus.api.DevStatusSummaryService
import com.atlassian.plugin.Plugin
import com.atlassian.plugin.PluginState
import com.atlassian.plugin.module.ContainerManagedPlugin
import ru.mail.jira.plugins.groovy.api.script.WithPlugin

@WithPlugin('com.atlassian.jira.plugins.jira-development-integration-plugin')
DevStatusSummaryService devStatusSummaryService = null

Plugin plugin = ComponentAccessor.pluginAccessor.getPlugin("com.atlassian.jira.plugins.jira-development-integration-plugin")

if (plugin instanceof ContainerManagedPlugin && plugin.pluginState == PluginState.ENABLED) {
def beans = plugin.getContainerAccessor().getBeansOfType(DevStatusSummaryService)

if (beans.size() > 0) {
devStatusSummaryService = beans.first()
}
}

return devStatusSummaryService

 For ScriptRunner you'll need to replace WithPlugin import with ScriptRunner one (no other changes are required, I think).

0 votes
Daniel Yelamos [Adaptavist]
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 23, 2017

Nir, as you can see, when you updated your platform, you now have a fugue.Either(which is some hideous objetct I must admit) instead of whatever you used to have.

This needs some heavy debuggin, but maybe can you try this line:

devStatusSummaryService.getDetailData(issue.id, "stash", "pullrequest", currentUser).right()

The right() method should return the object that the Either should have if the call was successfull. 

Cheers!

Dyelamos

Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 24, 2017

Hi Daniel,

 

Now i get another error (attach)

2017-08-24_15-03-17.jpg

 

Any suggestions?

Thanks,

Nir

Daniel Yelamos [Adaptavist]
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 24, 2017

What do you get when you do this:

def pullRequestData = devStatusSummaryService.getDetailData(issue.id, "stash", "pullrequest", currentUser).get()

 ?

Cheers

Dyelamos

Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 24, 2017

I get the first error:

 

[Static type checking] - Cannot find matching method

io.atlassian.fugue.Either#get(). Please check if the declared type is right and if the method exist.

Possible solutions: grep(), grep(java.lang.Object), getAt(java.lang.String), wait(), any(), wait(long), @line 12, column 30.

Daniel Yelamos [Adaptavist]
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 24, 2017

Apologies, what about this?

def pullRequestData = devStatusSummaryService.getDetailData(issue.id, "stash", "pullrequest", currentUser).right()  
Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 24, 2017

now i get:

java.lang.NullPointerException: Cannot invoke method getDetailData() on null object

Daniel Yelamos [Adaptavist]
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 24, 2017

Okay, that means that the way that you get objects have changed from version to version. 

I'm going to ask around for some Bitbucket heavyweights and see if I can find you a solution. Is this very urgent?

Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 24, 2017

Kind of... but I will wait of course.

Thank you for the help :)

Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 11, 2017

Hi Daniel, @Daniel Yelamos [Adaptavist]

Did you managed to look into it?

Deleted user December 6, 2017

@Daniel Yelamos [Adaptavist]

Running into the same problem here.

Has anyone solved this?

dralexk July 1, 2018

@Daniel Yelamos [Adaptavist]@Nir Haimov

Have you found a solution or a workaround? I need it too!

Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 1, 2018

Hi @dralexk @[deleted]

I accessed everything i need through REST API since i couldn't figure out the way with the code abouve

dralexk July 1, 2018

@Nir HaimovThanks for the update!

Mehmet Sari December 2, 2021

you can do it with this solution:

https://community.atlassian.com/t5/Answers-Developer-Questions/Access-development-information-from-groovy-script-runner-in/qaq-p/517778

 

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("TEST-2")
def details = service.getDetailData(issue.id, "stash", "pullrequest", currentUser).right().get().getDetail()

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events