Hello.
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?
Thanks.
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.
Cheers,
Shaun
Hello.
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":
https://developer.atlassian.com/display/JIRADEV/Issue+fields
I am probably missing something and would really appreciate your help.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+JIRA+Issue+CRUD+and+Search
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks everyone for help!!!
The final working solution is:
1. Get list of issues for the project(see doc at https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+JIRA+Issue+CRUD+and+Search)
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
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]]
*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=
2012-10-18T10:05:37.479-04:00,completeDate=<null>,id=2]]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nevermind. Looks like the group ID for the greenhopper has changed com.atlassian.plugins
with the artifactID jira-greenhopper-plugin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The REST api can get you the data, but I am not sure within the plugin how to handle the authentication.
Check /sprints/{rapidViewId}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.