I want to create JIRA tickets for tasks and bugs all at once! However, if you make one by one from JIRA's web form, it is quite troublesome to switch the text box for each item and select the item from the pull-down menu.
So today I've summarized how to create a JIRA ticket using Python. It wasn't often mentioned that it was a Japanese article,
I will also explain how to insert such as.
Install the JIRA package
pip install jira
Light usage etc. are also listed here https://pypi.python.org/pypi/jira/
As a test, I will try to extract ticket information from Atlassian's public JIRA
from jira import JIRA
jira = JIRA('https://jira.atlassian.com')
issue = jira.issue('JRA-10')
print (issue.fields.project.key) #Get the project key
print (issue.fields.issuetype.name) #Ticket type
print (issue.fields.reporter.displayName)#Reporter name
If you normally use JIRA for work, you should be able to view and post without logging in. So! Log in first!
from jira import JIRA
from jira.exceptions import JIRAError
options = {'server': '(URL of my JIRA)'}
usr = '(username)'
pas = '(password)'
try:
jira = JIRA(options=options, basic_auth=(usr, pas))
except JIRAError as e:
if e.status_code == 401:
print ("Login to JIRA failed.")
print ("Login!!")
If all goes well, you will see Login.
Next is the creation of tickets. Let's create a ticket with various items! Please note that the parentheses, id, name, etc. are slightly different depending on the item.
new_issue = jira.create_issue(
project='(Your project key)',
summary= '(wrap up)',
description= '(Description)',
issuetype={'name': '(Ticket type)'},
priority= {'id': '(priority[1 is the best])'},
assignee={'name': '(Person in charge)'},
components= [{"name": '(component)'}],
versions = [{"name": '(version)'}],
labels = ['(label)']
)
print ("Done!")
The priority is specified by number, but it must be entered as a character string. Also, if the component or version is not registered, an error will be displayed.
After that, depending on the application, ticket creation will progress collectively. I also tried to put together from Excel and turn tasks into tickets.
Recommended Posts