Chaos to Clarity: My Python App for Printing Jira Task Labels

Written in


Jira Label Creator

The Problem

Managing a plethora of tasks in Jira can sometimes feel like trying to keep track of every drop in an ocean. You’re in a meeting, and suddenly you’re asked about an old, closed task. Your mind races, but the details are fuzzy. It’s this very scenario, recurring more often than I’d like to admit, that drove me to find a solution. That’s how the concept of a Python app for creating adn print detailed Jira task labels, complete with QR codes, came to life.

The Idea

It all started with a simple need: to quickly access information about a task without having to navigate through the Jira website. The solution? A physical, printed label for each task, offering a snapshot of its essence and a QR code for those needing more. This way, the information wasn’t just a click away—it was right there, in the physical world, attached to related documents, pinned on boards, or even stuck on the edge of monitors.

The Printer

Thermal printers, known for their reliability and efficiency, provided the perfect match for the app’s requirements. Not only do these printers operate quietly and with minimal maintenance, but they also eliminate the need for ink or toner, which is a significant cost saver over time.

One of the best aspects of this setup is the affordability of thermal printers. After a bit of research, I opted for the Mafiti Mini Printer, priced at an incredibly affordable £18 on Amazon. The adhesive backing on the roll paper means that as soon as a label is printed, it can be directly applied to any surface—be it documents related to the task, notebooks, or even the edges of monitors. The printer’s compact size and ease of use mean it can comfortably fit within any workspace, from a bustling office to a home study, ensuring that printing detailed task labels is always just a few clicks away.

Mafiti Printer on Amazon

A Flask-Jira Integration for QR-Enabled Labels

The core of the application is built on Python, a choice driven by its flexibility and the rich ecosystem of libraries available for web development and image processing. The Flask framework serves as the backbone of the web app, facilitating the creation of a user-friendly interface where I can input the name/id of a Jira task. Upon submission, the app communicates with the Jira API to retrieve detailed information about the task, including its title, status, and description. The integration with the Jira API is crucial for accessing real-time data about tasks. Using the jira Python library, the app authenticates with Jira using API tokens and fetches task details based on the input URL or task ID. This direct link with Jira ensures that the labels are always up-to-date with the latest task information, providing a reliable source of truth for project status and details.
For the QR code generation, I utilized the qrcode Python library. Each QR code encapsulates the URL to the task in Jira, making it accessible with just a simple scan using any smartphone or QR code scanner. This feature is particularly beneficial in meetings or for anyone managing physical documents related to the project, as it allows for quick access to the digital task without the need to manually search within Jira.

The Code

Here’s a breakdown of the code with comments for clarity:

from flask import Flask, render_template, request, redirect, url_for
from jira import JIRA
import qrcode
import io
import base64
import os

app = Flask(__name__)  # Initialize Flask app

# Retrieve the API token from environment variables for security
api_token = os.environ.get('api_token')

# Jira connection setup with credentials and server information
jira_url = ''
username = 'yourjiraemailaccount' 

# Establish connection to JIRA with the provided credentials
jira = JIRA(basic_auth=(username, api_token), options={'server': jira_url})

@app.route('/', methods=['GET'])  # Define the route for the home page
def index():
    # Render the home page template (index.html)
    return render_template('index.html')

@app.route('/generate_label', methods=['POST'])  # Define the route to generate labels
def generate_label():
    jira_link = request.form.get('jiraLink')  # Get the JIRA link from form data
    if not jira_link:
        # If JIRA link is not provided, reload the form with an error
        return render_template('index.html', error="Please provide a Jira link.")

    issue_key = jira_link.split('/')[-1]  # Extract the issue key from the URL

        issue = jira.issue(issue_key)  # Fetch the issue details from JIRA

        # Prepare a summary of the issue for display and QR code generation
        recap = {
            'key': issue_key,
            'title': issue.fields.summary,
            'reporter': issue.fields.reporter.displayName,
            'description': issue.fields.description,
            'task_url': f'{jira_url}/browse/{issue_key}'

        # Setup QR code with specified configurations
        qr = qrcode.QRCode(
        qr.add_data(recap['task_url'])  # Add JIRA task URL to QR code
        qr.make(fit=True)  # Ensure the QR code is generated with optimal size
        img = qr.make_image(fill_color="black", back_color="white")

        # Convert QR code image to a format suitable for HTML embedding
        img_bytes = io.BytesIO(), format='PNG')
        qr_code_data = base64.b64encode(

        # Pass issue summary and QR code data to the template for display
        return render_template('task_details.html', recap=recap, qr_code_data=qr_code_data)
    except Exception as e:
        print(e)  # Print any errors encountered to the console
        # Reload the form with an error message if fetching JIRA task details fails
        return render_template('index.html', error="Error fetching Jira task.")

if __name__ == '__main__':  # Run the app in debug mode for development purposes

This Flask web application serves two main functions:

  1. Display a Form on the Homepage: When users visit the root URL ('/'), they’re presented with a form where they can input a JIRA link. This is handled by the index function, which renders index.html.
  2. Generate and Display JIRA Issue Details with QR Code: Upon form submission, the generate_label function is triggered. It extracts the issue key from the provided JIRA link, fetches the corresponding issue details from JIRA using the JIRA API, and generates a QR code that links to the JIRA issue. These details, along with the QR code, are displayed to the user on task_details.html.

The QR code generation is done using the qrcode library, and the resulting image is converted to a base64 string for easy embedding in HTML. If the JIRA link is missing or there’s an error fetching issue details, the user is shown an error message.

The application uses environment variables to securely manage the API token for JIRA authentication, showcasing best practices for sensitive information management in web applications.

The Results

The outcome is a highly practical tool that enhances the physical organization of tasks with digital insights. Whether it’s for personal use to stay organized or for teams to maintain clarity on project deliverables, the Python app serves as a bridge between the digital task management provided by Jira and the physical world where work gets done. By simplifying access to task details and ensuring that vital information is always within reach, the app aims to improve productivity and streamline project management practices.

In Conclusion

Let’s just say that developing this Flask app to spit out Jira task labels with QR codes was less about being a tech nerd and more about saving my own bacon. It simplifies the process of keeping track of tasks by linking the digital convenience of Jira with the tangible world through scannable codes. For anyone looking to streamline their project management process, this app offers a practical aid, reflecting a small but significant step towards blending digital task management with real-world action.