Forums

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

How to retrieve all sprints in a board (scriptrunner)

Marc Minten (EVS)
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.
April 27, 2022

Someone knows how to retrieve the sprints in a board using scriptrunner (java api).

The java doc for the whole agile part is not "very well" documented :-(

1 answer

0 votes
Anzar
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.
April 27, 2022

Hi Marc,

Thanks for reaching Atlassian Community.

You can find your answer here:
https://innovalog.atlassian.net/wiki/spaces/JMWE/pages/163348640/Fetch+the+current+active+sprint+of+a+Scrum+board

Let me know if this helps and/or if you need more help on this.

 

Regards,

Anzar

Thomas Beauné
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!
March 5, 2025

This page seems seems to be unreachable. Do you have the answer somewhere else ? 

Vladimir Verlin
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!
March 20, 2025

You can use something like this.

import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.service.sprint.Sprint
import com.atlassian.jira.component.ComponentAccessor as CA
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.greenhopper.service.sprint.SprintIssueService
import com.atlassian.greenhopper.service.sprint.SprintManager

// Specify that the script depends on the GreenHopper (Jira Agile) plugin
@WithPlugin("com.pyxis.greenhopper.jira")

// Inject dependencies using ScriptRunner's JiraAgileBean
@JiraAgileBean
RapidViewService rapidViewService

@JiraAgileBean
SprintIssueService sprintIssueService

@JiraAgileBean
SprintManager sprintManager

// Get the currently logged-in user
def loggedInUser = CA.getJiraAuthenticationContext().getLoggedInUser()

// Specify the ID of the board (Rapid View) for which to find the active sprint
def rapidBoardId = 181L

// Retrieve the board (RapidView) object using its ID
def view = rapidViewService.getRapidView(loggedInUser, rapidBoardId).getValue()

// Get all sprints associated with this board
def sprints = sprintManager.getSprintsForView(view).getValue()

// Filter sprints to find only the active ones
def activeSprint = sprints.findAll { it.active } //Remove active to get all sprints

// Log the active sprints for debugging purposes
log.warn(activeSprint)
Like Thomas Beauné likes this

Suggest an answer

Log in or Sign up to answer