The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Sprint Name from a Given Sprint ID

Rosy Salameh
Contributor
July 21, 2014

Hi,

I need to retrieve the sprint Name of a given Sprint ID (e.g. let's say we have SprintID = 101),

I have GreenHopper 6.1.5 on my Jira Instance 6.1.5, so, I put the following dependency in my pom.xml:

<dependency>

<groupId>com.atlassian.jira.plugins</groupId>

<artifactId>jira-greenhopper-plugin</artifactId>

<version>6.1.5</version>

<scope>provided</scope>

</dependency>

and inside my code, I injected SprintManager and I put:

log.debug("Sprint: " + sprintManager.getSprint(101).getValue().getName());

I obtained the following:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cust_single-stat-resource' defined in URL [bundle://282.0:0/META-INF/spring/atlassian-plugins-components.xml]: Unsatisfied dependency expressed through constructor argument with index 2 of type [com.atlassian.greenhopper.service.sprint.SprintManager]: : No unique bean of type [com.atlassian.greenhopper.service.sprint.SprintManager] is defined: Unsatisfied dependency of type [interface com.atlassian.greenhopper.service.sprint.SprintManager]: expected at least 1 matching bean; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.atlassian.greenhopper.service.sprint.SprintManager] is defined: Unsatisfied dependency of type [interface com.atlassian.greenhopper.service.sprint.SprintManager]: expected at least 1 matching bean

What I have missed?

Thanks,

Rosy

8 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
JamieA
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 Champions.
July 23, 2014

This is relatively straightforward in Script Runner 3, if you wanted to give that a try, eg:

import com.atlassian.greenhopper.service.sprint.SprintManager
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin

@WithPlugin("com.pyxis.greenhopper.jira")

@JiraAgileBean
SprintManager sprintManager

sprintManager.getSprint(10).getValue().getName()

Artem
July 26, 2016

Thank you so much!

Harish Kumar
May 30, 2020

Hi @JamieA , 

Hope you are good,

 

My scenario is to update sprint goal, with the board owner name when a sprint is closed via script listener. I am trying it but i failed many times. can you help me on this.

 

Thankyou

Harish Kumar

0 votes
Rosy Salameh
Contributor
July 29, 2014

Guys,

Maybe the answer posted here could help: https://answers.atlassian.com/questions/319207/does-anyone-know-how-to-implement-the-sprintmanager

Personally, I didn't try it as my specifications were modified and for the moment, I do not need to have all sprints , but we have the same request there, maybe, it could help.

Thanks,

Rosy

0 votes
David Frager _gmail_
July 27, 2014

CustomField sprint = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Sprint");

Issue issue = ComponentAccessor.getIssueManager().getIssueObject(issueId);

ArrayList<Sprint> list = (ArrayList<Sprint>) sprint.getValue(issue);

if(list != null) {
Iterator<Sprint> it = list.iterator();

while(it.hasNext()) {
Sprint current = it.next();
log.info("Sprint: {}", current.getName());
}
}

Rosy Salameh
Contributor
July 27, 2014

Thanks David, it works perfectly :) !!

Many thanks,

Rosy

0 votes
Rosy Salameh
Contributor
July 27, 2014

Hello David,

How did you get the Sprint object traversing through an issue? Can you please post some code?

I already asked this question (https://answers.atlassian.com/questions/319525/how-to-get-sprint-names-of-a-defined-issue#) but I didn't get any answer yet.

Many thanks,

Rosy

0 votes
David Frager _gmail_
July 24, 2014

I am attempting a similar implementation, and I also am seeing a null pointer after the call to SprintManager sprintManager = ComponentAccessor.getComponent(SprintManagerImpl.class);

Ajay _view26_
Community Champion
July 18, 2018

Hi David ,

 I am also facing the same issue with null pointer when accessing sprintManager via ComponentAccessor.getComponent.

Is there a way to get it working ?

0 votes
Rosy Salameh
Contributor
July 23, 2014

Thanks Jamie.

but there's no way to code that in a normal plugin other than Script RunneR?

Thanks,

Rosy

David Frager _gmail_
July 24, 2014

I am also seeing a null pointer after a call to SprintManager sprintManager = ComponentAccessor.getComponent(SprintManagerImpl.class);

David Frager _gmail_
July 25, 2014

I am able to successfully get a Sprint Object, traversing through an issue, so I am confident my local configuration is proper (POM.XML, etc). I need to have the ability to query and present a list of all active Sprints as a stand-alone entity.

0 votes
Rosy Salameh
Contributor
July 22, 2014

Thank you Jobin. The plugin was installed successfully when I added:

<component key="sprintManager" name="Sprint Manager" class="com.atlassian.greenhopper.service.sprint.SprintManagerImpl">

<interface>com.atlassian.greenhopper.service.sprint.SprintManager</interface>

</component>

But, I returns the following exception:

java.lang.NullPointerException at com.atlassian.greenhopper.service.sprint.SprintManagerImpl.getSprint(SprintManagerImpl.java:68)

in this line of code where the SprintManager was injected:

log.debug("Sprint: " + sprintManager.getSprint(101).getValue().getName());

although the class SprintManagerImpl is the suitable Jira Agile API Class 6.1.5.

My main request is to retrieve the sprint name of a given ID (here 101 for example).

Is there a way to get that? Did I miss something here?

Many thanks,

Rosy

Jobin Kuruvilla [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 Champions.
July 23, 2014

I am guessing some of the internal classess are not loaded in this case. Haven't tried this API before and so I am not sure. Maybe some one else will chime in ;)

0 votes
Jobin Kuruvilla [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 Champions.
July 21, 2014
Rosy Salameh
Contributor
July 21, 2014

Hi Jobin,

When I added the following:

<component-import key="sprintManager" interface="com.atlassian.greenhopper.service.sprint.SprintManager"/>

I obtained this error:
Never resolved service '&sprintManager' for plugin 'XXX.XXX.XXX' with filter (objectClass=com.atlassian.greenhopper.service.sprint.SprintManager)
Regards,
Rosy
Jobin Kuruvilla [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 Champions.
July 21, 2014
Rosy Salameh
Contributor
July 21, 2014

Thanks Jobin but when I added the following:

<component key="sprintManager" name="Sprint Manager"/> as suggested by the article, I obtained an error telling me: required class. My version is 6.1.5

Can you please help?

Thanks,

Rosy

Jobin Kuruvilla [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 Champions.
July 21, 2014

You wil need the class and the interface like this:

&lt;component key="sprintManager" name="Sprint Manager" class=""&gt;
  &lt;interface&gt;com.atlassian.greenhopper.service.sprint.SprintManager&lt;/interface&gt;
&lt;/component&gt;

Find out the class from the JIRA Agile APIs.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

TAGS
AUG Leaders

Atlassian Community Events