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

Greenhopper - Howto put an issue into sprint using groovy?

AlexanderR April 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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
AlexanderR May 1, 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:

https://answers.atlassian.com/questions/49588/how-can-i-access-the-list-of-gh-sprints-programmatically-from-workflow-post-functions

0 votes
Colin Goudie
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.
April 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.

0 votes
AlexanderR April 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 :-/

TAGS
AUG Leaders

Atlassian Community Events