【问题标题】:Get tag and sprint value from Jira using python使用 python 从 Jira 获取标签和 sprint 值
【发布时间】:2018-04-03 09:57:16
【问题描述】:

您能否帮助获取特定问题的标记和 Sprint 值

import jira.client
from jira.client import JIRA

options = {'server': 'https://example.com', 'verify':False}
jira = JIRA(options, basic_auth=('user', 'password'))
issues_in_project = jira.search_issues('project=11372 AND SPRINT not in 
closedSprints() AND sprint not in futureSprints()')
for value in issues_in_project:
print value.key , value.fields.summary , value.fields.assignee , 
value.fields.reporter ,value.fields.updated ,value.fields.resolutiondate, 
value.fields.duedate, value.fields.labels,value.fields.tag

运行python脚本时出现错误

DWD-9933 加载和验证产品用户名 username 2018-04-02T23:27:07.000-0700 无 2018-04-06 [u'DW-Products'] 回溯(最近一次通话最后): 文件“jira_test.py”,第 23 行,在 打印 value.key 、 value.fields.summary 、 value.fields.assignee 、 value.fields.reporter 、value.fields.updated 、value.fields.resolutiondate 、 value.fields.duedate 、 value.fields.labels 、value.fields 。标签 AttributeError:类型对象“PropertyHolder”没有属性“标签”

请看一次并帮助我实现这一目标

谢谢,

【问题讨论】:

    标签: python-2.7 api jira jira-rest-api python-jira


    【解决方案1】:

    对于标准属性,使用 getattr 内置方法和 field 名称(技术上是 id)。 有些字段可以自定义,它们的id 看起来像这样customfield_15100。以下是如何使用您的所有字段信息https://confluence.atlassian.com/jirakb/how-to-find-id-for-custom-field-s-744522503.html 获取JSON

    所以在您的情况下,tag 可能是一个自定义字段。

    for value in issues_in_project:
    
       # standart field
       print(getattr(value.fields(), 'reporter'))
       print(getattr(value.fields(), 'summary'))
    
       # custom field
       print(getattr(value.fields(), 'customfield_15100'))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-01
      • 2023-03-07
      • 2016-10-07
      • 2016-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多