From 999d03f7aa0c43d9ed984bcc2e124184c8bb5b7f Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 17 Apr 2025 18:51:50 +0300 Subject: [PATCH] Add Basic Authentication method for Jira Data Center/Server and validation script --- .../core-abilities/fetching_ticket_context.md | 63 ++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/docs/docs/core-abilities/fetching_ticket_context.md b/docs/docs/core-abilities/fetching_ticket_context.md index 3a0c9fd0..6418586a 100644 --- a/docs/docs/core-abilities/fetching_ticket_context.md +++ b/docs/docs/core-abilities/fetching_ticket_context.md @@ -165,7 +165,66 @@ jira_api_email = "YOUR_EMAIL" [//]: # (Personal Access Token (PAT) Authentication) -Currently, JIRA integration for Data Center/Server is available via Personal Access Token (PAT) Authentication method + +#### Using Basic Authentication for Jira Data Center/Server + +You can use your Jira username and password to authenticate with Jira Data Center/Server. + +In your Configuration file/Environment variables/Secrets file, add the following lines: + +```toml +jira_api_email = "your_username" +jira_api_token = "your_password" +``` + +(Note that indeed the 'jira_api_email' field is used for the username, and the 'jira_api_token' field is used for the user password.) + +##### Validating Basic authentication via Python script + +If you are facing issues retrieving tickets in Qodo Merge with Basic auth, you can validate the flow using a Python script. +This following steps will help you check if the basic auth is working correctly, and if you can access the Jira ticket details: + +1. run `pip install jira==3.8.0` + +2. run the following Python script (after replacing the placeholders with your actual values): + +??? example "Script to validate basic auth" + + ```python + from jira import JIRA + + + if __name__ == "__main__": + try: + # Jira server URL + server = "https://..." + # Basic auth + username = "..." + password = "..." + # Jira ticket code (e.g. "PROJ-123") + ticket_id = "..." + + print("Initializing JiraServerTicketProvider with JIRA server") + # Initialize JIRA client + jira = JIRA( + server=server, + basic_auth=(username, password), + timeout=30 + ) + if jira: + print(f"JIRA client initialized successfully") + else: + print("Error initializing JIRA client") + + # Fetch ticket details + ticket = jira.issue(ticket_id) + print(f"Ticket title: {ticket.fields.summary}") + + except Exception as e: + print(f"Error fetching JIRA ticket details: {e}") + ``` + +#### Using a Personal Access Token (PAT) for Jira Data Center/Server 1. Create a [Personal Access Token (PAT)](https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html) in your Jira account 2. In your Configuration file/Environment variables/Secrets file, add the following lines: @@ -176,7 +235,7 @@ jira_base_url = "YOUR_JIRA_BASE_URL" # e.g. https://jira.example.com jira_api_token = "YOUR_API_TOKEN" ``` -#### Validating PAT token via Python script +##### Validating PAT token via Python script If you are facing issues retrieving tickets in Qodo Merge with PAT token, you can validate the flow using a Python script. This following steps will help you check if the token is working correctly, and if you can access the Jira ticket details: