JQL: Get list of sprints
Asked Answered
I

9

15

Is it possible to get a list of sprints for a particular project ? I know there is a way to find issues by a sprint, but haven't found any way to get all the sprints.

Insuperable answered 24/6, 2014 at 7:36 Comment(2)
Are you using JQL in JIRA or in some application. AFAIK, JQL only returns Issues as results.Syphilis
Using it via their API.Insuperable
E
17

I use the following rest call to find all the sprints:

https://yourjira.com/rest/greenhopper/1.0/integration/teamcalendars/sprint/list?jql=project+%3D+YOURPROJECTKEY

To find only the open sprint of the project I run this: https://yourjira.com/rest/greenhopper/1.0/integration/teamcalendars/sprint/list?jql=project+%3D+YOURPROJECTKEY+and+Sprint+not+in+closedSprints()

Estivation answered 31/12, 2014 at 18:42 Comment(2)
Is there any documentation to refer?Toupee
how can I find the last closed sprint? tried using ORDER BY updatedDate DESC but this returns all the closed sprints.Havoc
S
11

In JQL it's not yet possible but you can use the new jira agile API. Here is the documentation for jira cloud and for jira server 7.2.3.

First, you need to find the board of your project. This REST endpoint to get the list of your boards is:

[jira-url]/rest/agile/1.0/board

Next you can get their project with:

[jira-url]/rest/agile/1.0/[board-id]/project

So in this manner you can find the board id of your project. At the end, you can get the sprints list of this board with:

[jira-url]/rest/agile/1.0/[board-id]/sprint

Susa answered 27/5, 2016 at 8:54 Comment(1)
thank you... however... it seems like it's actually: [jira-url]/rest/agile/1.0/board/[board-id]/sprint When I use that, it works perfectly!Mind
E
7
[jira-url]/rest/greenhopper/1.0/sprint/picker

Delivers "allMatches" array containing active sprints including id and boardName.

It was useful to me when i was searching a list of active sprints in all projects to clean up not completed or not well named sprints.

Epenthesis answered 3/7, 2015 at 14:54 Comment(0)
A
5

Based on this answer: answers.atlassian.com/questions/65920/answers/3599592, the best Web API to get the list of sprints is:

https://<your_site>/rest/greenhopper/1.0/sprintquery/<rapidBoardId>?includeFutureSprints=true&includeHistoricSprints=false

<rapidBoardId> is different in each system, I just saw it in the address bar of my browser when I was surfing in JIRA, then I hard coded it into the code which is calling the API.

https://<your_site>/secure/RapidBoard.jspa?rapidView=<rapidBoardId is here on your browser address bar>
Amble answered 10/3, 2015 at 16:19 Comment(0)
S
4

There is no REST endpoint to do this, you can only query the sprints that are visible for a particular Rapid Board and you need to use the GreenHoppper plugin for this.

The endpoint for that is: https://yourjira.com/rest/greenhopper/1.0/sprints/{rapidBoardId}

You can enumerate the Rapid Boards at another REST endpoint: https://yourjira.com/rest/greenhopper/1.0/rapidviews/list

Read more here: https://answers.atlassian.com/questions/65920/how-can-i-list-all-sprints-from-greenhopper-using-the-rest-api

Syphilis answered 24/6, 2014 at 8:7 Comment(0)
S
2

There is no straightforward solution, only workarounds. What is ridiculous why Jira doesn't provide such API calls.

You can use this endpoint:

https://api.atlassian.com/ex/jira/{cloudId}/rest/api/2/jql/autocompletedata/suggestions?fieldName=Sprint&fieldValue= 

Take notice of whitespace character on the end of query. It implies that every name of sprint includes whitespace char inside.

Output:

    {
        "results": [
            {
                "value": "2",
                "displayName": "Sprint 4 - 2020-06-17 04:00 (12)"
            },
            {
                "value": "1",
                "displayName": "Sprint 2 - 2020-06-20 06:45 (6)"
            }
    }
Sandlin answered 4/12, 2020 at 9:22 Comment(0)
M
1

I did not invent this, a colleague did. However, you can easily access all of the sprints in the "search issues" screen by using this JQL: Sprint is not EMPTY

That's it. Enjoy.

Mirthless answered 12/6, 2019 at 22:10 Comment(0)
A
0

Have you looked at the sprint report? The dropdown will show you a list of all sprints for that board. Of course you can have multiple boards per project, so you might need to search all related boards.

Afterglow answered 2/12, 2014 at 13:4 Comment(0)
M
0

Here is my solution.

  1. call rest/api/2/search?jql=project%20%3D%20ABCD%20AND%20Sprint%20in%20openSprints() to get the issues in current active sprint. Then you could get the active sprint.
  2. make another call rest/api/2/search?jql=Sprint%20%3D%2014343 to get the issues.

Below the code to parse the active sprint.

fetch(sprintUrl, {
      headers: requestHeader,
    })
      .then((res) => res.json())
      .then((data) => {
        const regex = new RegExp("state=ACTIVE");
        let activeSprint = data.issues[0].fields.customfield_14400.filter(
          (e: string) => regex.test(e)
        )[0];
        const sprintParser =
          /id=(\d+).*?name=(.*?),startDate=([\d-]+).*?endDate=([\d-]+)/g;
        const group = [...activeSprint.matchAll(sprintParser)][0];
        setSprint(
          Object.create({
            id: parseInt(group[1]),
            name: group[2],
            startDate: group[3],
            endDate: group[4],
          })
        );
      });
Mural answered 28/7, 2022 at 13:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.