Python is a Programming Language, popular for its rich libraries and easy-to-use syntax. Developers and Analysts alike prefer Python Programming language to implement Software Development and Machine Learning programs. Furthermore, nowadays companies are drawn towards the idea of Jira Python Integration. This is mainly because of the various benefits and functionalities that Python provides. Therefore, companies find it easier to manage their Jira data in Python Data Frames to gain more control and better results. 

This article will discuss Jira and Python and list down their key features. It will also provide a step-by-step guide for setting up the Jira Python Integration using 2 methods. The first method makes use of the Jira Library present in Python to transfer the data from Jira Tables into Python Dataframes. The second method is built-around APIs( Application Programming Interface) that can facilitate this data transfer process. Read along to learn these methods and the benefits associated with Jira Python Integration!

Prerequisites

  • An Atlassian account.
  • Working knowledge of Python Programming Language.
  • Working knowledge of APIs.

Introduction to Jira

Jira Python Integration: Jira Logo
Image Source

Jira is a software tool that works on Cloud and is popular for its Problem Tracking and Project Management properties. Companies deploying projects on Agile Methodology of software development are the main users of this tool. It’s a subscription-based service that helps teams achieve a common goal. Along with major tasks like Backlog Creation, Planning, and Product Delivery, this tool allows you to monitor and improve the overall progress of your project. Jira also works with many other tools to simplify Issue Tracking and promote the launch of new software products. 

Jira supports a Version Management feature that can track your projects and prepare detailed performance reports. It also offers design templates that your company can customize according to its Marketing Campaigns.

Key Features of Jira

Jira is a preferred choice for Issue Tracking due to its following features:

  • Security: Jira’s has Bug Tracking software which allows access only to teams that have the required authorization to work on the Bug Management. Moreover, Jira’s Default Authorization Scheme provides an added layer of security while projects are allocated to teams. 
  • Reports: Jira serves data obtained from Issue Tracking and Project Management in the form of visuals called Reports. These Reports are available in various forms and syntaxes for you to choose from. They act as the measurement tool from the initial phase to the product delivery and maintenance phase of a project.
  • Project Control: You can easily track the progress of your company’s current projects at any stage with the Jira Tracking Software. It deploys JQL (a customized version of SQL) to search through issues faster. Furthermore, Jira offers a simple drag and drop method for you to create backlog sprints seamlessly.

Introduction to Python

Jira Python Integration: Python Logo
Image Source

Python is a popular general-purpose Programming Language. Its versatility, coupled with its ease of use for beginners, has made it one of the most used Programming Languages ​​today. It is mostly used for Website and Software Development, Task Automation, Data Analysis, and Data Visualization.

Due to its simple syntax, many non-technical professionals such as Accountants and Scientists also use it for daily work such as organizing finances. The Python Programming Language serves as the main tool in Data Science to perform complex Statistical Calculations, create Machine Learning Algorithms, etc. 

Key Features of the Python Programming Language

The following features make Python the most popular Programming Language today:

  • Beginner Friendly: The Python Programming Language provides a hassle-free option for developers. It has a straightforward and easy-to-understand workflow that suits entry-level coders. Moreover, since It’s open-source, one can use and distribute it for commercial purposes free of cost.
  • Robust Applications: It has a simple syntax based on natural human-readable language. Thus making projects on Python Programming Language, is faster as compared to other Programming Languages. Furthermore, Its versatile nature allows its use for different tasks like Web Development and Machine Learning.
  • Large Communities: Due to Python Programming Language’s popularity, a large and active community of coders is available that contributes to this language’s set of modules and libraries. The vast support community ensures that if you or any other coder get stuck into a programming issue, a solution will be available easily. You just have to post your issue on these community pages.

Methods to Set Up the Jira Python Integration

It is preferable to analyze and modify data in Python Data Frames rather than in Jira Tables. To achieve this, you can set up a Jira Python Integration using the following methods: 

Method 1: Using the JIRA Library for Jira Python Integration

Python supports the JIRA library that allows you to connect with the Jira platform and manage your data. The following steps will guide you through this easy to implement this approach of the Jira Python Integration:

Step 1: Generate Authentication Token

Log into your Atlassian account and generate a token using this link. Save the token for use in upcoming steps. This token will authenticate your Python Jira Integration.

Step 2: Import the JIRA Library

Use the following pip command to install Jira for Python.

Now open a python compiler (for example anaconda) and import the Jira library that you just installed.

from jira import JIRA

Step 3: Construct a Client Instance

Construct a Client-instance that will request your required data from the Jira server. This will require the Server name (to which the client will send its data request) given by your Domain name. Moreover, the client will require authentication parameters like your email id and the token created in Step 1.

jiraOptions = {'server': "https://zxxxxxxpython.atlassian.net"}

The authentication parameter( to be used in the next step) will look like the following:

Step 4: Pass the Authentication Parameter

Now, pass the authentication parameters to configure the Client instance:

jira = JIRA(options=jiraOptions, basic_auth=("abxxxxxxh@gmail.com", "dejxxxxxxxxxxxxxxxxxxx7E"))

Step 5: Call the Required Instances

Now since your Client instance is ready, all that’s left is to export it. You can either call for all the instances related to a single project using the following code:

for singleIssue in jira.search_issues(jql_str='project = MedicineAppBugs'):
print('{}: {}:{}'.format(singleIssue.key, singleIssue.fields.summary,singleIssue.fields.reporter.displayName))

This will generate the output shown in the below image.

Jira Python Integration: Output
Image Source

Another option is to call only a single instance from your project. This requires the following code:

singleIssue = jira.issue('MED-1')
print('{}: {}:{}'.format(singleIssue.key,
                         singleIssue.fields.summary,
                         singleIssue.fields.reporter.displayName))

The output generated will be as shown in the below image.

Jira Python Integration: Output
Image Source

That’s it! Your Jira Python Integration is complete.

Method 2: Using the JIRA Rest API for Jira Python Integration

This method implements APIs to transfer the data from Jira to Python Data Frames. You can follow the below steps to set up the Jira Python Integration using APIs:

Step 1: Create the Authentication Token

Log into your Atlassian account and generate a token using this link. Save the token for use in upcoming steps. 

Step 2: Import Required Modules

Use the following code to Import the modules important for this process.

import requests
from requests.auth import HTTPBasicAuth
import json
import pandas as pd

Create a URL using your domain name to search for all issues related to your project.

url = "https://zxxxxxxpython.atlassian.net/rest/api/2/search"

Step 3: Create an Authentication Object

Now, you must create an authentication object that will include your email id and the token generated in Step 1. The following code will generate your authentication object.

auth = TPBasicAuth("abxxxxxxh@gmail.com", "dejxxxxxxxxxxxxxxxxxxx7E")

The following header will define the desired format in which you wish to get the output of your Jira Python Integration.

headers = { "Accept": "application/json"}

Mention your project name in the JQL query s shown in the below code. Otherwise, the API will fetch data from all the projects.

query = { 'jql': 'project =MedicineAppBugs '}

Step 4: Generate a Request Object

Now, generate a request object using JQL Query and authentication object of  Step 3.

response =requets.request(  "GET",  url,  headers=headers,  auth=auth,  params=query)

Use the following code to request for all the issues related to your project.

projectIssues = json.dumps(json.loads(response.text),                           sort_keys=True,indent=6,separators=(",", ": "))

You will get an output in the nested object which you should convert into a dictionary object for better understanding using the below code.

dictProjectIssues = json.loads(projectIssues)
listAllIssues = []
keyIssue, keySummary, keyReporter = "", "", ""

Step 5: Acess the Issues from your Project

All Issues from your Jira data are present, in the form of list elements, in the main API output. To access them, you need to loop through each element. Furthermore, since each Issue is also a nested dictionary object, apply the “iterateDictIssues” function, and fetch the required keys using the code below.

def iterateDictIssues(oIssues, listInner):

for key, values in oIssues.items():
    if(key == "fields"):
          fieldsDict = dict(values)
         iterateDictIssues(fieldsDict, listInner)
  elif (key == "reporter"):
         reporterDict = dict(values)
         iterateDictIssues(reporterDict, listInner)
elif(key == 'key'):
      keyIssue = values
      listInner.append(keyIssue)
elif(key == 'summary'):
       keySummary = values
       listInner.append(keySummary)
elif(key == "displayName"):
            keyReporter = values
            listInner.append(keyReporter)

for key, value in dictProjectIssues.items():
  
       if(key == "issues")
        totalIssues = len(value)
  
     
        for eachIssue in range(totalIssues):
            listInner = []  
           iterateDictIssues(value[eachIssue], listInner)  
           listAllIssues.append(listInner)

Step 6: Output the Results

The last step requires you to attach the output list, onto a Pandas’ data frame, and display the output.

dfIssues = pd.DataFrame(listAllIssues, columns=["Reporter","Summary","Key"])                                              
columnTiles = ["Key", "Summary", "Reporter"]
dfIssues = dfIssues.reindex(columns=columnTiles)
print(dfIssues)
Jira Python Integration: Output
Image Source

That’s it! Your Jira Python Integration using APIs is complete.

Advantages of Jira Python Integration

Now since you have understood the methods of setting up the Jira Python Integration, you should understand the importance of the same. Using Python with Jira will enhance your work in the following ways:

  • APIs are a convenient way to manage your Jira data. APIs provide you access to your data independently from the User interface. Jira API uses Python to transfer your data from Jira tables into a Pandas DataFrame. This provides you data in an independent form to clean, filter, or save it.
  • The Python modules have rich features that provide a simple way for you to manage and transform data, Moreover, it allows you to write custom scripts to visualize your data according to your requirements, something that is not possible while the data is stored in Jira. 
  • The Panda library is great at handling missing data. It has tools like series and data frames to manage both one-dimensional and 2-dimensional data. Furthermore, with the Jira Python Integration in place, you can merge, concatenate and reshape your Jira data easily. This allows you to transform the Jira Data in a form suitable for use.

Learn More About:

Setting up Wrike Jira Integration Simplified

Conclusion

This article introduced you to Jira and Python Programming Language along with their key features. It also explained 2 methods using which you can easily set up your Jira Python Integration and transfer your Jira data into Python Dataframes.

The first method uses the Jira Library present in Python to call the issue-tracking data of projects. The second method implemented the Jira APIs to transfer the data from Jira to Python’s Dataframes. Furthermore, the blog listed down the benefits of implementing the Jira Python Integration.

Share your views on the Jira Python Integration in the comments section!

Abhinav Chola
Research Analyst, Hevo Data

Abhinav Chola, a data science enthusiast, is dedicated to empowering data practitioners. After completing his Master’s degree in Computer Science from NITJ, he joined Hevo as a Research Analyst and works towards solving real-world challenges in data integration and infrastructure. His research skills and ability to explain complex technical concepts allow him to analyze complex data sets, identify trends, and translate his insights into clear and engaging articles.