Jira Rest JQL - How to grab all closed sprints pertaining to a project

Roberto L
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 25, 2017

Hello Community,

I am trying to write a JQL that grabs all the closed sprints pertaining to a certain project. 

I have the following JQL I am running in a Search Rest API:

'project' = 'Project-1' and sprints in closedSprints()

This returns me issues within the project that have the closedSprints() in them. From there I just JSON myself into the issue and grab the sprint that is attached to it.

For somereason, this JQL is only returning the most recent closed Sprint for the project. I would like to receive ALL of the closed sprints a project has ever had.

Would anyone know a solution to this.

I appreciate your time and expertise.

-Roberto

2 answers

1 accepted

1 vote
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 5, 2017

To the best of my knowledge the closedsprints() function in JQL is not limited to just returning recent sprints.  There is no mention of this in the documentation for this function either.  This function can return any issue if it exists in that closed sprint in this JIRA instance.   But the other aspect here is that JQL doesn't return sprint names directly. 

Instead JQL is return issues that meet that criteria.   So the way JIRA is doing this is by looking at the Sprint field on these issues.  An issue can exist in multiple sprints, so it can have multiple values for that field.  If any of the values in that field are closed sprints, then this issue itself should be returned by your query.

There are cases though I have seen where admins might want to remove old sprint field values from some issues.  This tends to happen if these issues need to be moved into a separate project and you don't want that sprint to also appear on the new board/project where this issue is moving.   If that happens, and someone edited the fields of these issues to remove values from the sprint field, that would prevent you from seeing such issues in the closesprint() function.   Alternatively if issues have been moved to other projects altogether (even without changing the sprint field), in turn they would not meet the project criteria of your JQL filter right now.  The same is true if the issues were deleted from JIRA. 

0 votes
BaZzz01010101 September 26, 2022

necro-posting /on

Try the reversed condition:

Sprint not in openSprints() and Sprint not in futureSprints()

necro-posting /off

Suggest an answer

Log in or Sign up to answer