How to get sprints using greenhopper api?


I need to get sprint from my class. I tried to use com.atlassian.greenhopper.service.sprint.SprintService, but I coudn't inject it. How can I get spints of project?


3 answers

1 accepted

Unfortunately there is no public service exported for this.

The only safe way to do this would be to get an issue that has that Sprint in its Sprint field, then query the custom field.

Alternatively you could use reflection to get access to the private SprintService you describe above, but because this is a private service we wouldn't recommend it.



Thank you very much for fast answer!

I am newbie with JIRA and Greenhopper plugins. Could you please assist a bit more. I do not see any trace of "sprint" field in documentation for "issue":

I am probably missing something and would really appreciate your help.


The REST api can get you the data, but I am not sure within the plugin how to handle the authentication.


Check /sprints/{rapidViewId}

Thank you very much - that helped!

/sprints/{rapidViewId} produces something like this:

{"sprints":[{"id":1,"name":"Sprint 1","closed":true},{"id":2,"name":"Sprint 2","closed":false}],"rapidViewId":1}

But the question still remains:
1.What issue field describes which sprint it belongs to?
2.If we know sprint ID - how do we get issues in this sprint?

Get the custom field values of the issue and Sprint is also a custom field as Shaun said. It should give the id as numeric value.

Getting issues in a sprint can be done using a JQL with Sprint = <<id>>, I guess it is the SearchService that will help you to do this.

Thanks everyone for help!!!

The final working solution is:

1. Get list of issues for the project(see doc at

2. for (Issue issue : issues){
CustomField customField = customFieldManager.getCustomFieldObjectByName( "Sprint" );

// retrieves the custom field value object from the issue
Object customFieldValue = issue.getCustomFieldValue( customField );

// prints value to console
System.out.println( customFieldValue );


3. Output prints similar to

* if issue was only in a single sprint:

[com.atlassian.greenhopper.service.sprint.Sprint@1bacc22[name=Sprint 1,closed=true,startDate=2

*if issue has been moved from sprint to sprint (not sure if this is an issue or done in purpose by jira):

[com.atlassian.greenhopper.service.sprint.Sprint@1bacc22[name=Sprint 1,closed=true,startDate=2
012-10-02T08:47:07.160-04:00,endDate=2012-10-05T08:47:00.000-04:00,completeDate=2012-10-04T10:04:47.556-04:00,id=1], com.atlassian.greenhopper.service.sprint.Sprint@186cee5[name=Sprint 2, closed=false,startDate=2012-10-04T10:05:37.479-04:00,endDate=

Thx for posting, I was having the same problem. I have been trying to cast the Sprint object from the custom field value (array of sprints). However, I get a ClassCastException. I made sure the greenhopper jar was added to my plugin, but it still says it cannot cast:

com.atlassian.greenhopper.service.sprint.Sprint to com.atlassian.greenhopper.service.sprint.Sprint

I even tried to get the at the getters using reflection but that failed. Finally as a work around I just parsed the toString output (yuck). Were you ever able to cast the Sprint object?

Nevermind. Looks like the group ID for the greenhopper has changed com.atlassian.plugins

with the artifactID jira-greenhopper-plugin

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 26, 2019 in Jira Software

How to prevent the propagation of unused project schemes, workflows & screens in Jira software

Atlassian ranks project attributes as the third most important factor impacting performance in the category of data. It’s not surprising, since project attributes are precisely the rules used to ma...

562 views 0 6
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you