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 https://answers.atlassian.com/questions/92681/how-to-get-sprints-using-greenhopper-api). Can you please advise?
Thanks,
Rosy