How To Get Sprint Number In Jira

JIRA, created by Atlassian, is a commonly used project management solution by agile teams to effectively plan, track, and oversee various projects. An important aspect of managing an agile project in JIRA is managing sprints, and you may occasionally need to access the sprint number for tasks such as reporting or monitoring team progress.

Unfortunately, JIRA does not provide an out-of-the-box solution to get the sprint number directly. But don’t worry, there is a workaround to get the sprint number using the ‘Sprint’ field of an issue and a bit of scripting. It might sound a bit tricky, but this blog post will guide you through the steps of retrieving the sprint number in JIRA.


You will need administrator rights in JIRA as well as access to the Script Runner plugin, which will allow you to execute scripts within JIRA.

Steps to Get Sprint Number in JIRA

Step 1: Access the Custom Field Context

Go to JIRA Administration -> Issues -> Custom fields. Find the ‘Sprint’ field and go to the ‘Context’ option of that field.

Step 2: Extracting the Sprint Number

Now you can use a Groovy script to extract the sprint number from the ‘Sprint’ field. The ‘Sprint’ field contains a string that looks like this:
com.atlassian.greenhopper.service.sprint.Sprint@6d8ef78c[id=123, rapidViewId=80, state=CLOSED, name=Sprint 1, startDate=2020-10-20T07:37:00.147Z, endDate=2020-12-29T07:37:00.147Z, completeDate=2020-12-15T06:37:00.099Z, sequence=123].

To extract the sprint number (‘id’ in the string), you can use the following script:

    def sprintField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName('Sprint')
    String sprint = issue.getCustomFieldValue(sprintField)
    String sprintId = (sprint =~ /id=(\d+)/)[0][1]

Step 3: Displaying the Sprint Number

After extracting the sprint number, you can display it in a custom field or use it for your custom logic. For instance, you can create a custom field named ‘Sprint Number’ and populate it with the sprint number using the Script Runner plugin.


While getting the sprint number in JIRA might require a bit of scripting, it isn’t too complicated with the right instructions. Make sure to follow the steps mentioned above, and you’ll be able to fetch the sprint number in no time.