How can we get the last closed sprints in a project using JIRA Rest API?

naveenkumar_dp December 6, 2019

Hi team,

I am looking for getting the last closed sprint in a JIRA Cloud instance project using Rest API.

any one help us on this.

Thanks

Naveen 

3 answers

0 votes
YY哥
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 30, 2023

Hi @Andy Heinzer  I've got the same requirement for my Forge app when there are a large dataset of sprints in a specific board. The App won't work normally. 

My App is called Sprint Reviewer to show all the sprint information in the Jira system: https://marketplace.atlassian.com/apps/1229698/sprint-reviewer?tab=overview&hosting=cloud

I've raised a ticket to Atlassian, but till now, haven't got the expected answer. Yeah, what I need is to extend the Rest API to support order by sprint id descending so that I can choose the latest 20 sprints for each board.

 

0 votes
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 17, 2019

Hi,

I understand you are looking for the last sprint closed in a project in Jira Cloud via the REST API.  There are a couple of problems that prevent this specific request.  First off: sprints are not bound specifically to a single project.  Sure you can set a sprint to only include issues from a single project, but the sprints have the ability to add any issues that could be included by the boards' filter.  Hence any given sprint could span several projects.  There is no clear way to only get back the last sprint that existed on a per project basis.

That said there is some information we could get from REST if we query the board itself, instead of the project.  First you need to know the board's ID number.  You can find this by visiting the board and looking at the URL for the rapidView number in the URL  OR you can look it up by first looking up all the boards that use the saved filter's id number.

Once you know the board id number, you can get all the sprints on that board with the endpoint GET /rest/agile/1.0/board/{boardId}/sprint.  There is not an endpoint to specifically retrieve the last sprint, so unfortunately, you would need to look at the state of each sprint on that board, and the endDate value and compare them against today's date/time.  This is one way you can determine via REST API results which sprint was closed last on that board.

I hope this helps.

Andy

Giridhar Reddy Mosay March 31, 2020

Atleast an "order by" support on GET /rest/agile/1.0/board/{boardId}/sprint would have been a great favour.

Like # people like this
YY哥
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 13, 2023

Unfortunately, there's still no this order by support currently.

sam.dawson May 24, 2023

The docs mention a "total" field but it does not seem to actually exist. If it did at least we could skip to the back of the results.

https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-rest-agile-1-0-board-boardid-sprint-get

0 votes
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 8, 2019

Hello,

After some research it seems that there is no option for this out of the box.

The addon scriptrunner have a previous sprint function but only works in jira server.

YY哥
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 25, 2023

Thanks Mobamed, you're correct. This issue is still pending on Atlassian developers. They think it's not a high priority requirement.

Suggest an answer

Log in or Sign up to answer