我们有一个更新jira票证的过程,我已使用以下代码并在python 6.4中使用JIRA软件包对其进行了自动化。效果很好...但是他们在流程中增加了一个新步骤,要求我单击“批准”按钮,以使“ customfield_12410”出现在单独的弹出窗口中,其中包含许多要更新的其他字段。< / p>
from jira.client import JIRA
jira_server = "http://jiraserver"
jira_password = f.read()
jira_user = getpass.getuser()
jira_server = {'server': jira_server}
jira = JIRA(options=jira_server, basic_auth=(jira_user, jira_password))
comment = "Test Results. Passes {0} Failed {1}".format(passed,failed)
# Get ticket information
jira_issue = jira.issue(ticketId)
jira_issue.update(fields={'customfield_12410': comment})
此代码现在生成的错误是:
text: Field 'customfield_12410' cannot be set. It is not on the appropriate
screen, or unknown.
如何单击Jira票证上的按钮。通过打印票证的原始内容,我看不到任何类似于按钮名称的东西。
print(jira_issue.raw)
谢谢
约翰。
答案 0 :(得分:0)
该按钮可能是工作流程的过渡。您可以使用REST API更改状态,例如https://community.atlassian.com/t5/Jira-questions/JIRA-How-to-change-issue-status-via-rest/qaq-p/528133和https://jira.readthedocs.io/en/master/examples.html#transitions
答案 1 :(得分:0)
使用以下代码解决
from jira.client import JIRA
jira_server = "http://jiraserver"
jira_password = f.read()
jira_user = getpass.getuser()
jira_server = {'server': jira_server}
jira = JIRA(options=jira_server, basic_auth=(jira_user, jira_password))
comment = "Test Results. Passes {0} Failed {1}".format(passed,failed)
# Get ticket information
jira_issue = jira.issue(ticketId)
transitions = jira.transitions(jira_issue)
for t in transitions:
print(t['id'], t['name'])
Output:
12 Approval
14 Cancel
# Resolve the issue with the comment
jira.transition_issue(jira_issue, '12', fields={'customfield_12410': comment})