Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,274
Community Members
 
Community Events
184
Community Groups

ScriptRunner/Groovy Cannot invoke method getSprintsForView() on null object

I'm attempting to use a ScriptRunner/Groovy script to give me a list of active and open (in progress & future) sprints in a specific board. For some reason, whenever I use the getSprintsForView() method, it fails and errors "cannot invoke method getSprintsForView() on null object".

The odd thing is that I check if the view is null, and the view seems to work just fine with other methods (like getOpenSprintsAndBacklogProjects. 

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.greenhopper.service.rapid.view.RapidViewService;
import com.atlassian.greenhopper.service.rapid.RapidViewQueryService;
import com.atlassian.greenhopper.model.rapid.RapidView;

import com.atlassian.greenhopper.service.sprint.Sprint;
import com.atlassian.greenhopper.service.sprint.SprintManager;

def sprintManager = ComponentAccessor.getOSGiComponentInstanceOfType(SprintManager.class);
def rapidViewService = ComponentAccessor.getOSGiComponentInstanceOfType(RapidViewService.class);
def rapidViewQueryService = ComponentAccessor.getOSGiComponentInstanceOfType(RapidViewQueryService.class);

board_id = 89L;

def sprints = [];
def sprints_two = [];


def view = rapidViewService.getRapidView(user, board_id).getValue();

if (view != null)
{
sprints = rapidViewQueryService.getOpenSprintsAndBacklogProjects(user, view).getValue().left();
sprints_two = sprintManager.getSprintsForView(view).getValue();
}

 

What am I doing wrong?

2 answers

1 vote
Thanos Batagiannis [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.
Mar 08, 2018

What if you try to get the sprintManager like 

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

SprintManager sprintManager = PluginModuleCompilationCustomiser.getGreenHopperBean(SprintManager)

Please let me know if this does the trick.

Regards, Thanos

it works!

thank you so much!

0 votes
Aleksandr Zuevich
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.
Mar 02, 2018

Hi,

Is sprintManager null?

That is indeed what was happening. SprintManager is apparently not exposed in the Jira API. 

As someone new to this type of work, it was unfortunately not very obvious this is the case from the API documentation. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events