Fetch data using Jira library for Python

JIRA, is a Python library, for connecting, with the JIRA tool. This library is easy to use, as compared, to the API method, for fetching data, related to Issues, Projects, Worklogs etc. The library, requires, a Python version, greater than 3.5.

Install jira using the command:

pip install jira

Approach:

  • Import the jira module.
  • Construct, a Jira client instance, using the following ā€“
    • The server key, which is your domain name, is created on Atlassian account.
    • Basic authentication parameters, your registered emailID, and, the unique token received.
  • Get a JIRA client instance bypassing, Authentication parameters.
  • Search all issues mentioned against a project name(Display the details, like Issue Key, Summary, Reporter Name, using the print statement.).

Below is the implementation:

Python




# import the installed Jira library
from jira import JIRA
  
# Specify a server key. It should be your
# domain name link. yourdomainname.atlassian.net
jiraOptions = {'server': "https://txxxxxxpython.atlassian.net"}
  
# Get a JIRA client instance, pass,
# Authentication parameters
# and the Server name.
# emailID = your emailID
# token = token you receive after registration
jira = JIRA(options=jiraOptions, basic_auth=(
    "prxxxxxxh@gmail.com", "bj9xxxxxxxxxxxxxxxxxxx5A"))
  
# Search all issues mentioned against a project name.
for singleIssue in jira.search_issues(jql_str='project = MedicineAppBugs'):
    print('{}: {}:{}'.format(singleIssue.key, singleIssue.fields.summary,
                             singleIssue.fields.reporter.displayName))


Output:

Issues data output using JIRA library.

Using the Jira library, we can, also, fetch details, of a single issue.

 The Key is a unique ID, of the Issue, details of which, we require. It is obtained, after adding an Issue, for a project, on the platform, while fetching details of a single issue, pass its UniqueID or Key.

Python




# import the installed Jira library
from jira import JIRA
  
# Specify a server key. It is your  domain 
# name link.
jiraOptions = {'server': "https://txxxxxxpython.atlassian.net"}
  
# Get a JIRA client instance, Pass 
# Authentication parameters
# and  Server name.
# emailID = your emailID
# token = token you receive after registration
jira = JIRA(options = jiraOptions, 
            basic_auth = ("prxxxxxxh@gmail.com",
                          "bj9xxxxxxxxxxxxxxxxxxx5A"))
  
# While fetching details of a single issue,
# pass its UniqueID or Key.
singleIssue = jira.issue('MED-1')
print('{}: {}:{}'.format(singleIssue.key,
                         singleIssue.fields.summary,
                         singleIssue.fields.reporter.displayName))


Output:

Details of one issue using the JIRA library

How to fetch data from Jira in Python?

Jira is an agile, project management tool, developed by Atlassian, primarily used for, tracking project bugs, and, issues. It has gradually developed, into a powerful, work management tool, that can handle, all stages of agile methodology. In this article, we will learn, how to fetch data, from Jira, using Python.

There are two ways to get the data:

  1. Using JIRA library for Python.
  2. Using the JIRA Rest API.

The configuration, required, in the Jira software tool, is as follows:

  1. Create a Jira user account.
  2. Create a domain name, add a project, and, record some issues, or, bugs. Our task is to fetch, issues data, using Python code.
  3. We need to have, a valid token, for authentication, which can be obtained, from link  https://id.atlassian.com/manage/api-tokens.

Issues recorded in JIRA tool for project ā€œMedicineAppBugsā€

JQL: JQL stands for Jira Query Language. It is an efficient way, of fetching, JIRA-related data. It can be used, in both, JIRA library, and, API approach, for obtaining data. This involves, forming queries, to filter information, regarding, relevant Bugs, Projects, Issues etc. One can use, combinations, of different operators, and, keywords, in the query.

Similar Reads

Fetch data using Jira library for Python

JIRA, is a Python library, for connecting, with the JIRA tool. This library is easy to use, as compared, to the API method, for fetching data, related to Issues, Projects, Worklogs etc. The library, requires, a Python version, greater than 3.5....

Fetch data using Jira Rest API

...

Contact Us