Create JIRA tickets using Python

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.

environment

Preparation

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

log in

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.

Creating a ticket

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

Create JIRA tickets using Python
Create a python GUI using tkinter
Easily create homemade RPA using Python
Start using Python
[Python] Create a Batch environment using AWS-CDK
Scraping using Python
[Hyperledger Iroha] Create an account using Python library
Create a web map using Python and GDAL
Create wav file from GLSL shader using python3
Create a Mac app using py2app and Python3! !!
Create a MIDI file in Python using pretty_midi
Operate Redmine using Python Redmine
Create a Python module
[Python] Create multiple directories
Data cleaning using Python
WiringPi-SPI communication using Python
Age calculation using python
Search Twitter using Python
Create a Python environment
Name identification using python
Notes using Python subprocesses
Try using Tweepy [Python2.7]
Create a data collection bot in Python using Selenium
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 1 ~
Create an image file using PIL (Python Imaging Library).
[Python] Create a ValueObject with a complete constructor using dataclasses
Create your first GDSII file in Python using gdspy
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 2 ~
Create a company name extractor with python using JCLdic
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 3 ~
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 4 ~
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 5 ~
[Python] Create an infrastructure diagram in 3 minutes using diagrams
Python notes using perl-ternary operator
Flatten using Python yield from
Scraping using Python 3.5 async / await
Save images using python3 requests
Create a Wox plugin (Python)
Create a function in Python
Create a dictionary in Python
Create "Typoglycemia" sentences using COTOHA
[S3] CRUD with S3 using Python [Python]
[Python] Try using Tkinter's canvas
Create 3d gif with python3
Try using Kubernetes Client -Python-
Create gif video in Python
Create ToDo List [Python Django]
Python notes using perl-special variables
[Python] Using OpenCV with Python (Basic)
Scraping using Python 3.5 Async syntax
Post to Twitter using Python
Start to Selenium using python
Search algorithm using word2vec [python]
Change python version using pyenv
python: Basics of using scikit-learn ①
# 1 [python3] Simple calculation using variables
Instrument control using Python [pyvisa]
Manipulate spreadsheets locally using Python
Python memo using perl --join
Create a python numpy array
[Python] Create an event-driven web crawler using AWS's serverless architecture