Jira:制作一份包含故事和报道的报告。阻止与版本

时间:2017-07-10 08:14:31

标签: jira python-jira

我工作的公司使用 Jira 来支持需求捕获&测试项目的阶段。我们将故事(即要求)分配给版本。作为一名测试工程师,我提出了一些错误,然后我在故事中将其称为“被阻止”。

我需要创建一个报告,列出每个版本以及与该版本相关的故事。当我提出错误时,我需要报告也填充错误(或实际上提出的任何其他问题)。

我无法直接在Jira中看到这样做的方法,但我找到了一个用于Python的Jira模块......我已经完成了以下工作,但现在我被卡住了;

从jira导入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

这会产生预期的输出;

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

从我发现的文档中,我看不出如何进一步返回任何进一步的内容,我指的是每个版本下的故事和(如果存在的话)我提出的错误。

请帮忙吗?谢谢你的关注。

1 个答案:

答案 0 :(得分:0)

我最终到达那里......有点......这是我通过取消“原始”财产找到的解决方案......

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"]