简体   繁体   中英

How to click a button on a Jira ticket using python and the JIRA module

We have a process to update a jira ticket which i have automated with the following code and using the JIRA package in python 6.4. Which worked perfectly... however they have added a new step to the process which requires me clicking an 'Approval' button in order for the 'customfield_12410' to appear in a separate pop up window with a load of other fields to update.

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

The error this code now generates is:

text: Field 'customfield_12410' cannot be set. It is not on the appropriate 
screen, or unknown.

How do i click a button on the Jira ticket. By printing the raw contents of the ticket, i don't see anything resembling the button name.

print(jira_issue.raw)

Thanks,

John.

Resolved with the following code

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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