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

Greenhopper - Howto put an issue into sprint using groovy?

AlexanderR Apr 25, 2013

I would like to put an issue into a sprint via a scriptrunner post-action.

My problem is that I cannot access the SprintIssueService. The following code will return sprintIssueService not found:

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.plugin.PluginAccessor

// get user and issue
def jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext()
def user = jiraAuthenticationContext.getUser()
Issue issue = ComponentAccessor.getIssueManager().getIssueObject("ABC-123")

// access greenhopper
PluginAccessor pluginAccessor = ComponentAccessor.getPluginAccessor();
Class greenHopperClass = pluginAccessor.getClassLoader().findClass("com.pyxis.greenhopper.GreenHopper");
def greenHopper = componentManager.getOSGiComponentInstanceOfType(greenHopperClass);

if (! greenHopper ) {
  return "greeenHopper not found"

// access SprintIssueService
Class sprintIssueServiceClass = pluginAccessor.getClassLoader().findClass("com.atlassian.greenhopper.service.sprint.SprintIssueService")
def sprintIssueService = componentManager.getOSGiComponentInstanceOfType(sprintIssueServiceClass);

if (! sprintIssueService ) {
  return "sprintIssueService not found"
} else { 
  return sprintIssueService.getSprintsForIssue(user, issue)

Can someone help?

3 answers

1 accepted

0 votes
Answer accepted
AlexanderR May 01, 2013

As one can only access the sprints via REST api, one has to use some HTTPClient (e.g. org.apache.commons.httpclient.HttpClient) to get it done.

The last post of the following shows a code example of that:

0 votes
AlexanderR Apr 25, 2013

That's sad but I think you are right. The sprintIssueService is not public/exposed and the only way to access it is via REST. So I have to rethink my idea with a post-action :-/

0 votes
Colin Goudie Apr 25, 2013

From my experience most of the Service objects from GreenHopper are not exposed to other plugins. You'd be best attempting to do it via the REST interface. Not that GH has a published REST interface but you can discover it fine using the Developer Tools plugin and REST browser in that.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Statuspage

⭐️Would you recommend Statuspage? Leave a (honest!) review. ⭐️

Hi Community friends, We're working on sourcing more reviews on Capterra – a popular software review site –  to help teams like yours make more informed decisions when choosing an inc...

82 views 3 5
Join discussion

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