How to get sprint names of a defined issue?

I need to get sprint names of a defined issue. At first, I thought that this can be done as all custom fields like this:

private static final long SPRINT_CUSTOM_FIELD_ID = 11160; // ID of Sprint CF in Jira 6.1.5;

CustomField customFieldSprint = customFieldManager.getCustomFieldObject(Long.valueOf(SPRINT_CUSTOM_FIELD_ID));

log.debug("Issue: "+ issue.getKey() +"Sprint Value: "+ getCustomFieldStringValue(issue, customFieldSprint));

Where getCustomFieldStringValue is the following:

public String getCustomFieldStringValue(Issue issue, CustomField customField) {

String customFieldStringValue = "";

Object value = issue.getCustomFieldValue(customField);

if(value == null){

customFieldStringValue = "";


else if(value instanceof Option) {

customFieldStringValue = ((Option) value).getValue();


else if(value instanceof String) {

customFieldStringValue = (String) value;


log.debug("Custom Field " + customField.getName() + " has the following string value: " + customFieldStringValue);

return customFieldStringValue;


But, I obtained an empty value.

I have noticed that the method getSprintsForIssue of com.atlassian.greenhopper.service.sprint.SprintIssueServiceImpl gets sprints for a defined issue, but I'm not be able to use it (it seems that there'no public services for this as mentioned in Can you please advise?



3 answers

Hi Rosy,

unfortunatly you are right, the SprintIssueService is not a public service. However, depending on your version of Jira and Agile you might be able to access the SprintManager class, which might be useful to your problem. But this only works for Agile and Jira versions <6.2.

In regards to your problems with the custom field, the content of this field is an ArrayList of the class Sprint. therefore your code will probably just keep and return its inital empty string. To access the content of the field you could try some code similar to this:

private void setSprintData(){
	ArrayList&lt;Sprint&gt; list = (ArrayList&lt;Sprint&gt;) ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Sprint").getValue(getIssue());
		Iterator&lt;Sprint&gt; it = list.iterator();
		String name = "";
		Long id = Long.MIN_VALUE;
			Sprint next =;
				name = next.getName();
		sprintName = name;
		sprintId = id;
		sprintName = "";
		sprintId = -2L;

Hey Marten,

I have the version 6.1.5, but SprintManager doesn't work with this version as well.

I tried your code and it works perfectly! :)

Thanks a lot for your help,


Hi Rosy,

always happy to help. but as far as I know SprintManager should work in your version. It is just very tricky to get it. Standard import via the pom file won't work, you have to do some more elaborated stuff, like posted in this question

Thanks Marten.

You are right! I only imported green hopper plugin classes in my pom.xml and defined this Class as a Component in my atlassian-plugin.xml. I wasn't aware of this tricky code.

Many Thanks,


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,728 views 17 21
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