因为status不算一个字段,所以不能在create_issue(issue_dict)时设置,会报错:{"status":"Field 'status' cannot be set. It is not on the appropriate screen, or unknown."}},需要创建后再修改:
python
from jira import JIRA
# 连接到你的 Jira 实例
jira = JIRA(server='https://your-jira-instance.com', basic_auth=('username', 'password'))
# 检索你要修改的问题(issue)
issue = jira.issue('PROJECT-123')
# 修改状态为 'In Progress'(假设状态的名称为 'In Progress')
transition_id = None
transitions = jira.transitions(issue)
for transition in transitions:
if 'In Progress' in transition['name']:
transition_id = transition['id']
break
if transition_id:
jira.transition_issue(issue, transition_id)
print("Issue status updated successfully.")
else:
print("Could not find 'In Progress' transition for the issue.")
在这个示例中,你需要将 'PROJECT-123'
替换为你要修改状态的实际问题的key。然后,代码将尝试找到将状态更改为 'In Progress' 的转换,并执行该转换。你可以根据你的实际需求修改状态的名称和代码逻辑。