Get Sprint Name for Issue

Overview

Obtain the name of the sprint that contains a specific issue.

Example

As a project manager, I want to know the sprints in which several issues are located — allowing me to plan efficiently. I can use this script as part of a larger script to obtain this information and view it at a glance.

Good to Know

  • You can get other attributes from the sprint, such as the id, specifying the corresponding attribute instead of name. Check all available attributes at the REST API response documentation.

Requirements

Jira Jira

// The issue key
final issueKey = 'TEST-1'

// Fetch the issue object from the key
def issue = get("/rest/agile/1.0/issue/${issueKey}")
    .header('Content-Type', 'application/json')
    .asObject(Map)
    .body

// Get all the fields from the issue as a Map
def fields = issue.fields as Map

// Get the Custom field to get the option value from
def sprintName = fields.sprint.name // Note change .name to .id to get the ID of the sprint.

"The name of the current Sprint is '${sprintName}'"
Discovered an issue? Report it here

Suggested for you