I am looking at bulk creating tickets within Jira through python using the JIRA module. I am taking the user inputs to insert them into a dictionary which then creates the ticket within my project in JIRA. This all works fine and the ticket gets created as I would want. However my issue comes when trying to loop through the creation of tickets until I specify a point?
I basically want it to take the user inputs, create the tickets then ask me if I want to create another one. If i specify the letter 'Y' it then prompts the user to fill in the input boxes again and creates another ticket and so on until i specify otherwise.
The code I currently have is:
decision = input("Do you want to create a ticket? ")
project = "My project"
if decision == 'Y':
issue_dict = {
'project': {'key':project},
'summary': input("Please provide a summary "),
'description' : input("please describe the issue "),
'issuetype':{'name': 'Story'},
'assignee': {"name": input("Who is this assigned to ")}
}
ticket_id = jira.create_issue(fields=issue_dict)
print("Created, ticket reference: ", ticket_id)
decision = input("Do you want to create another ticket? ")
else:
print("No more tickets")
The error that I get with this code is:
NameError: name 'jira' is not defined
Which is on line 14:
ticket_id = jira.create_issue(fields=issue_dict)
Any help would be greatly appreciated, apologies if its a silly error, I have little experience with python loops!
Thanks :)
Edit: I dont understand how to get the code to run back through the top once its gone through once, sorry!