0

The Company I work for uses Jira to support the requirement capture & test phases of a project. We assign stories (i.e. requirements) to a release. As a Test Engineer, I raise bugs which I then reference in the story as "Is Blocked By".

I need to create a report which lists each of the releases and the stories associated with that release. As I raise bugs, I need the report to also be populated by the bugs (or actually any other issue raised).

I cannot see a way of doing this within Jira directly but I have found a Jira module for Python... I've got the following working but now I'm stuck;

from jira import JIRA

server = {"server" : "https://jira.pxr5.hw"}
login = ('bob', 'dave')

jira = JIRA (options = server, basic_auth = login)

myProject = jira.project ("QSC")

for eachVersion in myProject.versions:
    print eachVersion.name + " - " + eachVersion.id

This produces the expected output;

Release 0 - 10518
Release 0.1 - 10602
Release 0.2 - 10603
Release 1.0 - 10519
Release 2.0 - 10520
Release 3.0 - 10521
closed - 10616
work complete - 10617

From the documentation I've found, I cannot see how to return anything further by which I mean the stories under each Version and (where they exist) the bugs I've raised.

Please can you help? Thanks for your attention.

Alireza
  • 100,211
  • 27
  • 269
  • 172

1 Answers1

0

I got there in the end... Kind of... Here's a solution I found by unpicking the "raw" property...

from jira import JIRA
import sys

userName = "Dave"
userPassword = "Bob"

server = {"server" : "https://jira.pxr5.hw"}
login = (userName, userPassword)

# Open a link to Jira
jira = JIRA (options = server, basic_auth = login)

# Return an object comprising the project we're working on
myProject = jira.project ("quark")

# Get a list of the releases in the project.  Notice that the version
# has to be surrounded by single quotes as it may have spaces in it
for eachVersion in myProject.versions:
    jqlStatement = "project=quark AND fixVersion='" + eachVersion.name + "'"
    print eachVersion.name

    # Get a list of stories accociated with each release of the project
    theStories = jira.search_issues (jqlStatement)

    # Go through each story in the current release
    for eachStory in theStories:
        # The story is indented one tab with it's ID and summary name
        print "\t" + eachStory.raw["key"] + " " +  eachStory.raw["fields"]["summary"]

        # Now get a list of issue links and go through each one
        issueLinks = eachStory.raw["fields"]["issuelinks"]
        for eachLink in issueLinks:
            print "\t\t" +  eachLink["inwardIssue"]["key"] + " " + \
                        eachLink["inwardIssue"]["fields"]["summary"]
  • This works, but it requires you to do a search of the database for every version. If you have lots of issues, it will be pretty slow. If most or all of your issues are associated with a fixVersion, then it would be faster to get the complete list of issues, and create a dictionary with the fixVersion as the key and a list of issues associated with that fixVersion as the value. Also, you can get at the field values using the .fields object: eachStory.fields.key and eachStory.fields.summary will return the value you want – ZeddZull Jul 12 '17 at 14:43