How to get Sprint information using Java API ?

Sevak Asadorian November 8, 2017

Is there a way to retrieve the following information for a given Sprint using Jira or greenhopper Java API:

start date
end date
Number of Issues
Number of Sub-tasks per Issue
Number of "Done" Sub-tasks per Issue and their Resolved date

 

Please advise. Thanks in advance.

5 answers

0 votes
UX Software
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 10, 2024

To retrieve sprint information in Jira using the Java API, you should use com.atlassian.greenhopper.service.sprint.SprintService instead of SprintManager.

The SprintManager service is intended for internal use and may be unstable in user applications. In contrast, SprintService, though marked as ExperimentalApi, allows for a more reliable way to connect and retrieve sprint details.

For example, you can use the following code:

ServiceOutcome<Sprint> sprintServiceOutcome = sprintService.getSprint(user, sprintId);


This method provides a secure way to access sprint information.

0 votes
Caela Northey
Contributor
December 14, 2017

Hi @Sevak Asadorian,

This is late, but I'm working on a similar project for JIRA v7.3 and found that you can get some info about a sprint from the (java) API using the CustomField.getValue() method. This method returns the sprint name, id, start and end dates, and a few more in a list that you can then parse.

I posted about it a little here: 

https://community.atlassian.com/t5/Jira-discussions/Custom-Sprint-Report-getting-sprint-info-from-Java-API-JIRA/m-p/688870#M1691

Hope it helps!

h December 14, 2017

you are right,i can use Sprint when i import greenhopper. SprintManager can't work yet;

0 votes
h November 25, 2017

how use SprintManager ?you method can't work;

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 9, 2017

Use sprintManager.getSprint() to fetch it (or if you don't have the id, look at SprintQueryService).

Then I think it's probably SprintHelper to fetch details from it.

Sevak Asadorian November 9, 2017

Which way is prefered? (when developing a plugin)

This plugin is going to generate a burndown chart.

 

Is there some sample code that I can look at? (I am  using Jira 7.5)

Most, if not all solutions posted online are outdated :\

Sevak Asadorian November 9, 2017

If you can point to anything at this point that can help, I would greatly appreciate it!

I tried searching for a Java REST client and I found this:

jrjc

and

jira-client

 

The moment I touch my pom.xml file (by adding the dependency), I get this

atlassian-jira.log:2017-11-09 14:28:58,810 localhost-startStop-1 ERROR [c.a.p.osgi.factory.OsgiPluginInstalledHelper] Cannot determine required plugins, cannot resolve bundle 'com.atlassian.tutorial.myPlugin'

and this

atlassian-jira.log:2017-11-09 14:29:04,510 localhost-startStop-1 ERROR [c.a.p.osgi.factory.OsgiPlugin] Detected an error (BundleException) enabling the plugin 'com.atlassian.tutorial.myPlugin' : Unresolved constraint in bundle com.atlassian.tutorial.myPlugin [172]: Unable to resolve 172.0: missing requirement [172.0] osgi.wiring.package; (osgi.wiring.package=com.sun.xml.fastinfoset.sax). This error usually occurs when your plugin imports a package from another bundle with a specific version constraint and either the bundle providing that package doesn't meet those version constraints, or there is no bundle available that provides the specified package. For more details on how to fix this, see https://developer.atlassian.com/x/mQAN

when i atlas-run.

Which results into my plugin getting disabled and my corrupted (i can never get it enabled again). Luckily I have a backup copy that I can refer to when this happens.

This is telling me that a piece of the puzzle is missing or incompatable (aka outdated).

 

help.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 9, 2017

SprintManager if you have the sprint Id already, but SprintQueryService if you need to search.

Sevak Asadorian November 9, 2017

Dumb question:

how do you use SprintManager.

sample code?

 

tried this:

 

SprintManager sm = ComponentAccessor.getComponent(SprintManagerImpl.class);
0 votes
Support Valiantys
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 8, 2017

Hello, you could use JIRA api Rest to retrieve Sprint information :

rest/greenhopper/1.0/sprintquery/[rapidviewID]"

Related discussion :

https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-access-Sprint-details-using-Api/qaq-p/512783

Sevak Asadorian November 9, 2017

Is this true even if I am creating a plugin?

I can't use the Java API?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events