-->

Using JIRA Query Language from Klipfolio To Query

2019-09-21 01:50发布

问题:

I am trying to query the JIRA API from Klipfolio, to return all issues whos status = "rejected" in a given month, and the number of times each issue's status = "rejected".

Example queries I have run:

  1. Give me the issue history for a given issue which contains rejected issues. But I don't know how to return the number of times the issue's status = "rejected" from this query:

    https://upvate.atlassian.net/rest/api/2/project/UC?expand=changelog.

  2. Give me the the number of issues whos status = "rejected" for a given project and sprint:

    https://upvate.atlassian.net/rest/api/2/search?jql=project="UC" and sprint="21" and status="rejected"

But I need all issues whos status = "rejected" in a given month, and the number of times each issue's status = "rejected".

回答1:

  1. To determine which issues have been rejected, you will need to construct a JQL statement and insert that into the query. If you want to see the changelog for any issue that has been rejected, the query will look like this:

    https://upvate.atlassian.net/rest/api/2/search?jql=project='UC' and status = 'rejected'&expand=changelog&maxResults=100

The expand=changelog will add a JSON array to each issue object with a revision history of each change made to that issue. In case you have more than the default 50 issues per call, you can use the maxResults parameter (maxResults=100) which will bring the number of issues up to the max per call set by JIRA of 100. If you have more than that you will need to use the startAt parameter to paginate through the pages of issues.

  1. Like the above, you will need to create a JQL statement and insert it into the query url.

    https://upvate.atlassian.net/rest/api/2/search?jql=project = 'UC' and sprint = '21' and status = 'rejected' and createdDate >= 2017-12-01 AND createdDate <= 2017-12-31&maxResults=100

This will successfully return data from project UC for sprint 21 that has been rejected and created within the month of December 2017. If you want to filter the data by a relative date range; for example, the previous month, you can utilize Klipfolio's date parameters. To have the above query always return data for the previous month's with the same conditions, the query will look like so:

https://upvate.atlassian.net/rest/api/2/search?jql=project = 'UC' and sprint = '21' and status = 'rejected' and createdDate >= {date.addMonths(-1).startOfMonth.format()} AND createdDate <= {date.addMonths(-1).endOfMonth.format()}&maxResults=100