From 8ab30b8948d35b5e424cc8c1d9db889936ed757a Mon Sep 17 00:00:00 2001 From: Michal Kalinowski Date: Sun, 22 Sep 2024 12:23:49 +0200 Subject: [PATCH] script for pulling issues for the user --- main.py | 50 +++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | Bin 0 -> 854 bytes 2 files changed, 50 insertions(+) create mode 100644 main.py create mode 100644 requirements.txt diff --git a/main.py b/main.py new file mode 100644 index 0000000..34c4c63 --- /dev/null +++ b/main.py @@ -0,0 +1,50 @@ +from ssl import SSLCertVerificationError +import requests +from requests.auth import HTTPBasicAuth +import json +from dotenv import load_dotenv +import os + +# Before running the script make sure the following: +# 1. The correct root certificate is in the script directory and specified +# under the global variables +# 2. You've created the .env file with the following format: +# JIRA_USER= +# JIRA_PASSWORD= +# 3. You have installed necessary packages from the requirements.txt file + +load_dotenv() + +JIRA_URL = 'https://globaljira.roche.com/rest/api/2/issue/picker' +USERNAME = os.getenv("JIRA_USER") +PASSWORD = os.getenv("JIRA_PASSWORD") +ROOT_CERT = ".\\Roche G3 Root CA.crt" + +headers = { + 'Content-Type': 'application/json' +} + +query = { + 'query': f'assignee = {USERNAME} AND status not in (Closed, Done)' +} + +print(f'{USERNAME}, {PASSWORD}') + +try: + response = requests.get( + JIRA_URL, + auth=HTTPBasicAuth(USERNAME, PASSWORD), + headers=headers, + params=query, + verify=ROOT_CERT + ) +except SSLCertVerificationError: + print("SSL verification failed. Please make sure you're connected to the VPN and the correct root certificate is included.") + +if response.status_code == 200: + print("JQL query executed successfully!") + issues = json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")) + print(issues) +else: + print(f"Failed to execute JQL query. Status code: {response.status_code}") + print("Response:", response.text) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..8db13564f3bf4e4ba09020b953ea183452eee622 GIT binary patch literal 854 zcmZXT%}&EG5QO)P#G@27X$4%k@gAr@fdtYfv?(n-Jn+qKoD?c6wrtPN&a5{--wW%k zwuS8(73dH1RV{#4QDl(zMLf~lB(RJ)|^X)qSkf-U%QGa zh&#T_QIFiVuobp~uXC)pQr+=IF1_UVp8qiu7%yE2FCC%bGNvP{LAAQ6CfB)^h*58zhI4ga zVoUudM1hZD&>0=t(aWles`bR}sdp^A`a67$eHxWM@an2#g{IlSIQl+vum57ydamgg DAHaZ7 literal 0 HcmV?d00001