10

I'm getting started working with the JIRA REST API. I've learned how to get all the issues assigned to the current user:

rest/api/2/search?jql=assignee=currentuser()

...now I am trying to filter those by the current sprint. I think this functionality is provided by the JIRA Agile (Greenhopper) plugin, but I can't find any documentation for it. I came across some interesting data which appears to be the identifier for the sprint that the issue is assigned to:

customfield_10005: [
  "com.atlassian.greenhopper.service.sprint.Sprint@3094f872[rapidViewId=30,state=CLOSED,name=Sprint 2014-06-02,startDate=2014-06-02T00:00:37.672-07:00,endDate=2014-06-08T11:59:00.000-07:00,completeDate=2014-06-09T10:23:13.983-07:00,id=45]"
]

...but it just looks like a serialized mess. How can I query for the issues assigned to the current sprint?

Andrew
  • 227,796
  • 193
  • 515
  • 708
  • I have never worked with jira agile, but maybe you could use this as a starting point? https://confluence.atlassian.com/display/JIRA/Advanced+Searching+Functions#AdvancedSearchingFunctions-openSprints() – Seb Aug 08 '14 at 19:23

1 Answers1

11

The method you are looking for is

openSprints()

Its only working with JIRA Agile Version 6.5 or higher.

//* EDIT: Greenhopper got renamed to JIRA Agile *//

The method definition is:

Search for issues that are assigned to a Sprint which has not yet been completed. (Note that it is possible for an issue to belong to both a completed Sprint(s) and an incomplete Sprint(s).)

So this should work for you then

assignee in (currentUser()) AND sprint in openSprints()

Regards

CodeFanatic
  • 11,434
  • 1
  • 20
  • 38
  • 1
    So use the REST API resource that lets you run a search and use the openSprints() as part of the JQL passed to the search – mdoar Aug 12 '14 at 20:08
  • so adjust your answer like "This is a two way process: first, define a filter ... then second make a rest call that uses that filter ... " or "Use the rest API call [search](https://bunjil.jira-dev.com/plugins/servlet/restbrowser#/resource/api-2-search) and inside the parameter jql, use ..." – mliebelt Dec 25 '14 at 21:16
  • @mliebelt "Use the rest API call search and inside the parameter jql, use ..." the OP already has that part in his Question, or am I totally fuzzy right now? – CodeFanatic Dec 26 '14 at 12:40
  • The devil is in the details. We have made some experiences with the JIRA REST API the past 6 months, and sometimes, there are some subtleties that have to be made explicit. So what is the syntax to use your query "assignee in ..." inside the REST API call? – mliebelt Dec 26 '14 at 13:42
  • [Check out this answer to get the active sprint for a specific project key](http://stackoverflow.com/a/27725082/1975259) – weeksdev Jan 02 '15 at 15:16
  • 1
    @mliebelt as in my Answer jql=assignee%20in(currentUser())AND%20sprint%20in%20openSprints() – CodeFanatic Jan 07 '15 at 07:22