This repository contains two main Python scripts: ai_labeling.py
and webhook_handler.py
.
These scripts are designed to automate the labeling of JIRA issues using AI and handle JIRA webhooks for issue creation and updates.
This script uses an AI model to generate relevant labels for JIRA issues based on the combined information of the issue's summary, description, project name, and issue type. It then adds these labels to the corresponding JIRA issue.
This script sets up a Flask web server to handle JIRA webhooks for issue creation and updates.
When a new issue is created or updated, it processes the event and adds labels to the issue using the functionality provided in ai_labeling.py
.
- Flask==3.0.3
- groq==0.8.0
- python-dotenv==1.0.1
- Requests==2.32.3
-
Clone the repository:
git clone https://github.com/Okura66/Jira_AI_labels.git
-
Install dependencies:
pip install -r requirements.txt
-
Rename
.env sample
file in.env
and fill with the following content:JIRA_API_URL=<your_jira_api_url> JIRA_API_EMAIL=<your_jira_email> JIRA_API_TOKEN=<your_jira_api_token> GROQ_API_KEY=<your_groq_api_key>
This script can be run directly to generate and add labels to a JIRA issue. The main
function provides an example of how to use the ai_labeling
and add_label
functions.
This script sets up a Flask web server to handle JIRA webhooks.
python webhook_handler.py
The server will be accessible at http://localhost:5000. It provides two main routes:
- /webhook-handler: Handles POST requests from JIRA webhooks for issue creation and updates.
- /debug-info: A simple GET route to verify the server is running.
You can use NGROK for local test with jira cloud https://dashboard.ngrok.com/get-started/setup/
- ai_labeling(combined_info):
- Generates labels using the AI model.
- Parameters: combined_info (str) - Combined information of the issue's summary, description, -project name, and issue type.
- Returns: labels (str) - Generated labels separated by commas.
- add_label(label_string, issue_key):
- Adds labels to a JIRA issue.
- Parameters:
- label_string (str) - Labels generated by the AI model.
- issue_key (str) - Key of the JIRA issue to add labels to.
- webhook_handler():
- Main route for handling JIRA webhooks.
- debug_info():
- Debug route to display hosting information.
- handle_issue_created(data):
- Handles JIRA issue creation events.
- Parameters:
data
(dict) - JSON data from the webhook event.
- handle_issue_updated(data):
- Handles JIRA issue update events.
- Parameters:
data
(dict) - JSON data from the webhook event.
For registering a webhook in JIRA, see https://developer.atlassian.com/server/jira/platform/webhooks/