Script to find an origin board for a given Sprint

Overview

Find an origin board where a given Sprint was created.

Example

I am a Jira Administrator and a User contacts me that he is not able to complete a given Sprint. At a first look the User has the Manage Sprint permission in the given project but the Complete Sprint button is still greyed out.

As the Manage Sprint permission is controlled by filter query on the origin board it is necessary to grant the Manage Sprint permission to all of the projects related to the query.

As a Jira Administrator I need to quickly and easily find the origin board for the Sprint so that I can quickly check in the boards filter query in which projects the User needs the Manage Sprint permission.

As described in the JSWSERVER-13265 there is currently no easy way to do it through the Jira UI. The workaround suggests a database SQL query but not all Jira Administrators have the possibility to directly query the database. This script offers a workaround available for Jira Administrators through the UI of Scriptrunner Console without the necessity of database access.

Good To Know

  • Script is using the Dynamic Forms so a text input should appear above the script where you put a Sprint name and it is not necessary to modify the script at all.

  • Sprints are found based on their names using a similar search (not exact)

  • When multiple Sprints with the similar name exists it should list all of them line by line, including their IDs so that they can be better recognized

  • Output includes a name of the Sprint, Sprints ID with a link to the Sprint report and the Origin Board ID with a direct link to the Boards configuration where the JQL query and affected Projects can be seen

  • Script can be used in Scriptrunner Console or saved in the Script Editor and then later used in the Scriptruner Console

  • There is a hard-coded limitation in the script so that it will list only 1000 sprints (in general the limit probably won’t be reached)

import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.atlassian.greenhopper.service.sprint.SprintService
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.parameters.annotation.*

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

@JiraAgileBean
SprintService sprintService

@ShortTextInput(label = "Sprint Name", description = "Enter a Sprint Name")
String issueSummaryTextInput

@Checkbox(label = "Exclude completed Sprints", description = "If checked it will not return completed Sprints and return only active Sprints.")
Boolean excludeCompleted

if(issueSummaryTextInput == null) {
    return "<strong><span style='color: red;'>Please fill in the Sprint name!</span></strong>"
}

if(excludeCompleted == null) {
    excludeCompleted = false
}

def authenticationContext = ComponentAccessor.jiraAuthenticationContext
def user = authenticationContext.loggedInUser
def baseUrl = ComponentAccessor.getApplicationProperties().getString("jira.baseurl")

def sprintsByName = sprintService.findSprintsByName(user, issueSummaryTextInput, 1000, excludeCompleted)

String output = ""
if(sprintsByName != null && sprintsByName.get().size() > 0) {

    if(sprintsByName.get().size() == 1000) {
        log.warn("1000 sprints found, modify script!")
    }

    sprintsByName.get().each {
        output += it.getName() + " (ID: ";
        output += "<a href ='" + baseUrl + "/secure/RapidBoard.jspa?rapidView=" + it.getRapidViewId() + "&view=reporting&chart=sprintRetrospective&sprint=" + it.getId() + "' target='_blank'>"
        output += it.getId()
        output += "</a>"
        output += "), <strong>Board ID: <a href='" + baseUrl + "/secure/RapidView.jspa?rapidView=" + it.getRapidViewId() + "&tab=filter' target='_blank'>" + it.getRapidViewId() + "</a></strong><br />"
    }
} else {
    output += "<span style='color: purple;'><strong>No Sprint found with given name!</strong></span>"
}

return output

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.