Python-Jira无法更新问题状态

时间:2019-06-15 23:54:52

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

我正在尝试使用jira-python更新jira的状态。我的代码没有抛出任何错误,但是没有任何更新,问题的状态保持不变(我是初学者,尝试学习python)

project = jira.projects('project=')
for project in projects:
    if issue.fields.status in ('pending'):
       jira.transition_issue(issue, transition='closed')
   print('')
   return "successful"

3 个答案:

答案 0 :(得分:1)

您似乎要获取project个对象,但要更新issue个对象

在此处快速参考文档后:

https://jira.readthedocs.io/en/master/examples.html#searching https://jira.readthedocs.io/en/master/examples.html#transitions

我认为这段代码应该更适合于更新已关闭的问题:

issues_in_project = jira.search_issues('project=PROJECT_NAME')
for issue in issues_in_project:
    if issue.fields.status in ('pending'):
        jira.transition_issue(issue, '2')
   print('')
return "successful"

注意:

将PROJECT_NAME替换为要更新问题的项目名称,或者如果不想按项目进行过滤,则完全删除'project=PROJECT_NAME'

此外,根据docs过渡ID,“ 2”应用于“关闭问题”。

答案 1 :(得分:0)

不确定jira,但是我会更新您的迭代器或变量

projects = jira.projects('project=')
for project in projects:
    if issue.fields.status in ('pending'):
        jira.transition_issue(issue, transition='closed')
    print('')
    return "successful"

答案 2 :(得分:0)

已解决的问题,下面是代码: issues_in_proj = jira.search_issues('project = TEST')

  for issue in issues_in_proj:
        if ("Pending" in issue.fields.status.name):
              jira.transition_issue(issue, 'ID')

现在,我希望过滤具有组件名称/ Id膨胀以及状态添加条件的问题:( issue.fields.status.name中为“待处理”,issue.fields.components中为“组件名称”)。但这不是过滤组件