Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.service.sprint.SprintIssueService
import com.atlassian.greenhopper.service.sprint.SprintManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
* Configurable section
// Enter the name of the board to which you want to add the issue to the first active sprint
def rapidBoardId = 2L
RapidViewService rapidViewService
SprintIssueService sprintIssueService
SprintManager sprintManager
Issue issue = issue // provided in binding
def loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def view = rapidViewService.getRapidView(loggedInUser, rapidBoardId).getValue()
if (! view) {
log.warn("No view with this ID found")
def sprints = sprintManager.getSprintsForView(view).getValue()
def activeSprint = sprints.find { }
log.debug activeSprint
if (activeSprint) { "Adding issue $issue to ${}"
sprintIssueService.moveIssuesToSprint(loggedInUser, activeSprint, [issue] as Collection)
else { ("No active sprints were found for board: ${}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment