0

I'm trying to set up an integration that allows us to report daily on our current sprint's issues, subtasks and the status of each, using Zapier.

Ideally I'd run some python that loops through the JIRA response I get back to return a list of issues with their name, status, but not if the issue's issue type is name:"Sub-task".

The two calls I make are:

  1. Get active sprint

https://company.atlassian.net/rest/agile/1.0/board/51/sprint?state=active

  1. Get issues in the sprint

https://company.atlassian.net/rest/agile/1.0/sprint/<value_from_above>/issue?fields=key,status,summary,issuetype&maxResults=200

This gives a JSON output of all tickets, in the following format:

{
    expand: "schema,names",
    startAt: 0,
    maxResults: 200,
    total: 97,
    issues: [
        {
            expand: "operations,versionedRepresentations,editmeta,changelog,renderedFields",
            id: "43685",
            self: "https://company.atlassian.net/rest/agile/1.0/issue/43685",
            key: "ENG-431",
            fields: {
                summary: "Summary",
                issuetype: {
                    self: "https://company.atlassian.net/rest/api/2/issuetype/4",
                    id: "4",
                    description: "An improvement or enhancement to an existing feature or task.",
                    iconUrl: "https://company.atlassian.net/secure/viewavatar?size=medium&avatarId=10610&avatarType=issuetype",
                    name: "Improvement",
                    subtask: false,
                    avatarId: 10610
                },
                status: {
                    self: "https://company.atlassian.net/rest/api/2/status/10010",
                    description: "",
                    iconUrl: "https://company.atlassian.net/images/icons/statuses/closed.png",
                    name: "Done",
                    id: "10010",
                    statusCategory: {
                        self: "https://company.atlassian.net/rest/api/2/statuscategory/3",
                        id: 3,
                        key: "done",
                        colorName: "green",
                        name: "Done"
                    }
                }
            }
        },
        {
            expand: "operations,versionedRepresentations,editmeta,changelog,renderedFields",
            id: "45729",
            self: "https://company.atlassian.net/rest/agile/1.0/issue/45729",
            key: "ENG-636",
            fields: {
                summary: "Summary",
                issuetype: {
                    self: "https://company.atlassian.net/rest/api/2/issuetype/5",
                    id: "5",
                    description: "The sub-task of the issue",
                    iconUrl: "https://company.atlassian.net/secure/viewavatar?size=medium&avatarId=10616&avatarType=issuetype",
                    name: "Sub-task",
                    subtask: true,
                    avatarId: 10616
                },
                status: {
                    self: "https://company.atlassian.net/rest/api/2/status/10010",
                    description: "",
                    iconUrl: "https://company.atlassian.net/images/icons/statuses/closed.png",
                    name: "Done",
                    id: "10010",
                    statusCategory: {
                        self: "https://company.atlassian.net/rest/api/2/statuscategory/3",
                        id: 3,
                        key: "done",
                        colorName: "green",
                        name: "Done"
                    }
                }
            }
        },
        {
            expand: "operations,versionedRepresentations,editmeta,changelog,renderedFields",
            id: "45727",
            self: "https://company.atlassian.net/rest/agile/1.0/issue/45727",
            key: "ENG-634",
            fields: {
                summary: "Summary",
                issuetype: {
                    self: "https://company.atlassian.net/rest/api/2/issuetype/1",
                    id: "1",
                    description: "A problem which impairs or prevents the functions of the product.",
                    iconUrl: "https://company.atlassian.net/secure/viewavatar?size=medium&avatarId=10603&avatarType=issuetype",
                    name: "Bug",
                    subtask: false,
                    avatarId: 10603
                },
                status: {
                    self: "https://company.atlassian.net/rest/api/2/status/10010",
                    description: "",
                    iconUrl: "https://company.atlassian.net/images/icons/statuses/closed.png",
                    name: "Done",
                    id: "10010",
                    statusCategory: {
                        self: "https://company.atlassian.net/rest/api/2/statuscategory/3",
                        id: 3,
                        key: "done",
                        colorName: "green",
                        name: "Done"
                    }
                }
            }
        }
    ]
}

Ideally it'd show like the following:

"Issue 1" | Issue type | To do

"Issue 2" | Issue type | In Progress

"Issue 3" | Issue type | Done

"Issue 4" | Issue type | In Progress

Any ideas greatly appreciated, thanks!


Update:

I'm receiving the data back from Zapier in this format (https://i.stack.imgur.com/9Xf18.png), so I'm wondering if those calls should be made in one Python code execution, and parsing the results to give the output listed above.

tectomics
  • 137
  • 1
  • 10
  • Is there a must for using python? You could also use JQL to get this result with a filter like "project = MyProject AND Sprint in openSprints()" and then just showing the JIRA field columns you need (Key | IssueType | Status). This would also eliminate the problem of your audience's python knowledge level. For more information, see [Atlassian documentation](https://confluence.atlassian.com/jiracorecloud/advanced-searching-functions-reference-765593719.html#Advancedsearching-functionsreference-openSprintsopenSprints()). – Christopher Graf Aug 15 '19 at 09:31
  • What is the output of this report? This can definitely be done but how is this information being consumed? Emailed spreadsheet, BI tool, Email body, etc? – guitarhero23 Aug 21 '19 at 16:40

1 Answers1

0
import json
json_data = 'your_json_data'
d = json.loads(json_data)
for i, issue in enumerate(d['issues']):
    print("issue "+str(i)+' | '+ issue['fields']['issuetype']['name'] + ' | ' + issue['fields']['status']['name'])
Poojan
  • 3,366
  • 2
  • 17
  • 33
  • @KlausD. You want me to use `f"issue {i} | {issue['fields']['issuetype']['name']} | {issue['fields']['status']['name']}"` ? Kept it simple not knowing the audience understanding level in python. – Poojan Aug 14 '19 at 19:10
  • The audience's level of python is a big ol' 0. – tectomics Aug 14 '19 at 21:37
  • @Poojan Unfortunately, The responses I get back from Zapier are broken out, which is a shame, I'm wondering if I'm able to make these calls in code and print the results in this format... https://i.imgur.com/MEOTGxL.png – tectomics Aug 15 '19 at 08:43