Files
3-S/project/JIRA_cloud_connect.py
2025-05-09 11:17:15 +02:00

34 lines
1.2 KiB
Python

from atlassian import Jira
jira_url = 'https://3sit.atlassian.net/'
jira_user = 'markus.zimmerberger.external@eviden.com'
jira_token = 'ATATT3xFfGF0XqXNXhYn-PYvTDHRfaToOkIuvhdZFRBOwWRAn_XdqVg3vfmKz-TTXY9zNaQZOUW4JQTP_yGZn5lE60lWJaXzw4p055CccHohgsTtX9tKbFDieqsTK4n3z-eb3rW2KUi-ezLYjfi-_iK7PiOl5X0WPoCZOSn6e4ksPCjilsA2I0c=370351A3'
# Obtain an API token from: https://id.atlassian.com/manage-profile/security/api-tokens
# You cannot log-in with your regular password to these services.
jira = Jira(
url=jira_url,
username=jira_user,
password=jira_token,
cloud=True)
user = jira.username
if user:
print(f'Connected to JIRA as: {user}')
else:
print('Failed to connect to JIRA')
# Define a JQL query to fetch one JIRA ticket
jql_query = 'created >= -30d order by created DESC' # Adjust the JQL query as needed
max_results = 1 # Limit the results to one ticket
# Fetch the ticket(s) using the JQL query
tickets = jira.jql(jql_query, limit=max_results)
if tickets and tickets.get('issues'):
ticket = tickets['issues'][0]
print(f"Fetched JIRA ticket: {ticket['key']} - {ticket['fields']['summary']}")
else:
print('No tickets found or failed to fetch tickets')