简体   繁体   English

Python-Jira无法更新问题状态

[英]Python-jira unable to update issue status

i am trying to update jira status with jira-python. 我正在尝试使用jira-python更新jira状态。 My code doesn't throw any error but nothing is gets updated ,the status of the issues remains same(I'm beginner trying to learn python) 我的代码没有引发任何错误,但是没有任何更新,问题的状态保持不变(我是初学者,尝试学习python)

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

You seem to fetch project objects but you want to update issue objects 您似乎要获取project对象,但要更新issue对象

After a quick reference to the docs here: 在这里快速参考文档后:

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

I think this code should be more suitable to for updating issues to closed: 我认为这段代码应该更适合于将问题更新为已关闭:

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"

Notes: 笔记:

Replace PROJECT_NAME with name of your project for which you want to update issues, or remove 'project=PROJECT_NAME' at all if you don't want to filter by project. 将PROJECT_NAME替换为您要更新问题的项目的名称,或者如果您不想按项目进行过滤,则完全删除'project=PROJECT_NAME'

Also, according to the docs transition id '2' should be for 'Close Issue'. 另外,根据docs过渡ID,“ 2”应代表“未解决的问题”。

Not sure about jira, but I would update your iterator or your variable 不确定jira,但我会更新您的迭代器或变量

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

fixed issue, below is the code: issues_in_proj = jira.search_issues('project=TEST') 已修复的问题,下面是代码:issue_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')

Now I'm looking to filter issues with component name/Id swell along with status added condition : ("Pending" in issue.fields.status.name and "component name" in issue.fields.components) . 现在,我希望过滤具有组件名称/ Id膨胀以及状态添加条件的问题:( issue.fields.status.name中的“待处理”和issue.fields.components中的“组件名称”)。 But it's not filtering the components 但这不是过滤组件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM