如何使用python和JIRA模块单击Jira票证上的按钮

时间:2019-06-04 10:19:34

标签: python jira jira-rest-api

我们有一个更新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)

谢谢

约翰。

2 个答案:

答案 0 :(得分:0)

答案 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})