首页 > 解决方案 > 如何导出 JIRA 评论

问题描述

我使用 Python JIRA 库来导出项目内容。除了注释之外,大多数字段都是正常的。以下是我的代码,需要帮助指出错误所在。为什么会出现错误:非常感谢。

"Traceback (most recent call last):
    comments=item.fields.comment.comments
AttributeError: type object 'PropertyHolder' has no attribute 'comment'". 
from jira import JIRA
import pandas as pd
import openpyxl

jira = JIRA("http://jira-ep.ecp.priv")
block_size = 1000
block_num = 0
allissues = []

while True:
    start_idx = block_num * block_size
    issues = jira.search_issues(
        'project=PRJ0404 and type=DFM',
        start_idx,
        block_size
    )

    if len(issues) == 0:
        break

    block_num += 1

    for issue in issues:
        allissues.append(issue)

dfm = pd.DataFrame()

for item in allissues:
    d = {
        'key': item.key,
        'PCB': item.fields.customfield_10424,
        'Summary': item.fields.summary,
        'Severity': item.fields.customfield_10323,
        'Description': item.fields.description,
        'Reporter': item.fields.reporter,
        'Assignee': item.fields.assignee,
        'Create Stage': item.fields.customfield_10324,
        'Created Date': item.fields.created[0:10],
        'Updated Date': item.fields.updated[0:10],
        'Status': item.fields.status,
    }
    solution = ""
    comments = item.fields.comment.comments
    for comment in comments: # Get DFM comment filed content
        solution = comment.created[0:10] + 
            " " + 
            str(comment.author.name) + 
            ": " + 
            comment.body
    d = {'Solution': solution}
    dfm = dfm.append(d, ignore_index=True)

标签: pythonjirajira-pluginpython-jira

解决方案


推荐阅读