Summary
I wanted to share some of my trials and tribulations while working on a custom sprint report for Jira Software (v7.3) server using the Plugins2 framework, in case there were others trying to do the same.
Context
I started this project before knowing that the agile features of JIRA Software are not exposed in the Java API. After some digging found suggestions to use the REST API, which did have access to agile entities. This involved building a little HTTP client in my code from scratch (since Jira Java REST API Client is not supported past JIRA v6 because of course it isn't).
Important part
While I was testing my client however, I found that in fact, you can get a good amount of information about sprints from the Java API using the getValue() method of the CustomField class. That is, you can get access to an instance of CustomField object that represents an issue's sprints from the CustomFieldManager class (provided by the ComponentAccessor class, for example), and then call the getValue() method, which returns a list of info about the sprint. You can then parse the list for the needed info (using regex patterns, for example).
An example of the output of getValue() is shown below. This issue was in two sprints, Sprint 1 and Sprint 2. Sprint 1 is closed and started on 2017-05-31, while Sprint 2 is a Future sprint with no start date, etc.
[com.atlassian.greenhopper.service.sprint.Sprint@77e7bf34[id=225,rapidViewId=161,state=CLOSED,name=Sprint 1,startDate=2017-05-31T10:31:07.779-05:00,endDate=2017-06-07T10:31:00.000-05:00,completeDate=2017-12-11T14:12:16.082-06:00,sequence=225], com.atlassian.greenhopper.service.sprint.Sprint@68792939[id=400,rapidViewId=161,state=FUTURE,name=Sprint 2,startDate=,endDate=,completeDate=,sequence=400]]
Conclusion
If the report you're making requires any of this info, you don't need to access the REST API, and can get it from the Java API.
- Sprint name
- Agile board ID
- Sprint state
- Sprint start date
- Sprint end date
- Sprint completed date
I hope this info is helpful for anyone in my position who just wants to make some basic custom sprint reports!
References