Merge pull request #1705 from qodo-ai/tr/basic_auth

Add Basic Authentication method for Jira Data Center/Server and valid…
This commit is contained in:
Tal
2025-04-17 19:14:47 +03:00
committed by GitHub

View File

@ -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: