Get Sprint Name from a Given Sprint ID

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

This widget could not be displayed.

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()

Thank you so much!

This widget could not be displayed.

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

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

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.

This widget could not be displayed.

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

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 ;)

This widget could not be displayed.

Thanks Jamie.

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

Thanks,

Rosy

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

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.

This widget could not be displayed.

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

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 ?

This widget could not be displayed.

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

This widget could not be displayed.

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());
}
}

Thanks David, it works perfectly :) !!

Many thanks,

Rosy

This widget could not be displayed.

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted 6 hours ago in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

26 views 0 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you