t-bug-catcher 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/PKG-INFO +1 -1
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/setup.cfg +1 -1
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/setup.py +1 -1
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher/__init__.py +1 -1
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher/bug_catcher.py +3 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher/bug_snag.py +27 -23
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher/jira.py +30 -11
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher.egg-info/PKG-INFO +1 -1
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/MANIFEST.in +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/README.rst +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/pyproject.toml +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/requirements.txt +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher/config.py +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher/exceptions.py +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher/utils/__init__.py +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher/utils/common.py +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher/utils/logger.py +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher/workitems.py +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher.egg-info/SOURCES.txt +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher.egg-info/dependency_links.txt +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher.egg-info/not-zip-safe +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher.egg-info/requires.txt +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/t_bug_catcher.egg-info/top_level.txt +0 -0
- {t_bug_catcher-0.2.0 → t_bug_catcher-0.2.1}/tests/test_t_bug_catcher.py +0 -0
|
@@ -28,6 +28,7 @@ class Configurator:
|
|
|
28
28
|
api_token: str,
|
|
29
29
|
project_key: str,
|
|
30
30
|
webhook_url: Optional[str] = None,
|
|
31
|
+
default_assignee: Optional[str] = None,
|
|
31
32
|
):
|
|
32
33
|
"""Configures the JiraPoster and BugSnag classes.
|
|
33
34
|
|
|
@@ -36,6 +37,7 @@ class Configurator:
|
|
|
36
37
|
api_token (str): The API token for the Jira account.
|
|
37
38
|
project_key (str): The key of the Jira project.
|
|
38
39
|
webhook_url (str, optional): The webhook URL for the Jira project. Defaults to None.
|
|
40
|
+
default_assignee (str, optional): The default assignee for the Jira project. Defaults to None.
|
|
39
41
|
|
|
40
42
|
Returns:
|
|
41
43
|
None
|
|
@@ -45,6 +47,7 @@ class Configurator:
|
|
|
45
47
|
api_token=api_token,
|
|
46
48
|
project_key=project_key,
|
|
47
49
|
webhook_url=webhook_url,
|
|
50
|
+
default_assignee=default_assignee,
|
|
48
51
|
)
|
|
49
52
|
|
|
50
53
|
def bugsnag(self, api_key: str):
|
|
@@ -28,30 +28,34 @@ class BugSnag:
|
|
|
28
28
|
Returns:
|
|
29
29
|
bool: True if the configuration was successful, False otherwise.
|
|
30
30
|
"""
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
try:
|
|
32
|
+
bugsnag.configure(api_key=api_key, release_stage=CONFIG.ENVIRONMENT, auto_notify=False)
|
|
33
|
+
bugsnag.add_metadata_tab(
|
|
34
|
+
"Metadata",
|
|
35
|
+
{
|
|
36
|
+
"run_url": variables.get("processRunUrl", ""),
|
|
37
|
+
"run_by": variables.get("userEmail", ""),
|
|
38
|
+
},
|
|
39
|
+
)
|
|
40
|
+
response = requests.request(
|
|
41
|
+
"POST",
|
|
42
|
+
"https://otlp.bugsnag.com/v1/traces",
|
|
43
|
+
headers={
|
|
44
|
+
"Content-Type": "application/json",
|
|
45
|
+
"Bugsnag-Api-Key": api_key,
|
|
46
|
+
"Bugsnag-Payload-Version": "4",
|
|
47
|
+
"Bugsnag-Sent-At": f"{datetime.now().strftime('%Y-%m-%dT%H:%M:%S.%f')}",
|
|
48
|
+
"Bugsnag-Span-Sampling": "True",
|
|
49
|
+
},
|
|
50
|
+
data='{"message": "test"}',
|
|
51
|
+
)
|
|
52
|
+
if response.status_code not in [200, 201, 202, 204]:
|
|
53
|
+
logger.warning(f"Error connecting to Bugsnag: {response.text}")
|
|
54
|
+
return False
|
|
55
|
+
return True
|
|
56
|
+
except Exception as ex:
|
|
57
|
+
logger.warning(f"Failed to configure Bugsnag: {ex}")
|
|
53
58
|
return False
|
|
54
|
-
return True
|
|
55
59
|
|
|
56
60
|
def report_error(self, exception: Optional[Exception] = None, metadata: Optional[dict] = None):
|
|
57
61
|
"""Sends an error to BugSnag.
|
|
@@ -52,6 +52,7 @@ class Jira:
|
|
|
52
52
|
self._project_key = None
|
|
53
53
|
self._webhook_url = None
|
|
54
54
|
self._auth = None
|
|
55
|
+
self._default_assignee = None
|
|
55
56
|
|
|
56
57
|
@staticmethod
|
|
57
58
|
def _is_json_response(response) -> bool:
|
|
@@ -88,7 +89,9 @@ class Jira:
|
|
|
88
89
|
f"{exc_message}Status Code: {response.status_code}, " f"Headers: {response.headers}"
|
|
89
90
|
)
|
|
90
91
|
|
|
91
|
-
def config(
|
|
92
|
+
def config(
|
|
93
|
+
self, login, api_token, project_key, webhook_url: Optional[str] = None, default_assignee: Optional[str] = None
|
|
94
|
+
) -> bool:
|
|
92
95
|
"""Sets the webhook URL for the Jira project.
|
|
93
96
|
|
|
94
97
|
Args:
|
|
@@ -96,22 +99,28 @@ class Jira:
|
|
|
96
99
|
api_token (str): The API token for the Jira account.
|
|
97
100
|
project_key (str): The key of the Jira project.
|
|
98
101
|
webhook_url (str): The webhook URL for the Jira project.
|
|
102
|
+
default_assignee (str, optional): The default assignee for the Jira project. Defaults to None.
|
|
99
103
|
|
|
100
104
|
Returns:
|
|
101
105
|
bool: True if the configuration was successful, False otherwise.
|
|
102
106
|
"""
|
|
103
|
-
self._project_key = project_key
|
|
104
|
-
if not webhook_url:
|
|
105
|
-
logger.warning("No JIRA webhook URL provided. All issues will be posted to backlog.")
|
|
106
|
-
self._webhook_url = webhook_url
|
|
107
|
-
self._auth = self._authenticate(login, api_token)
|
|
108
107
|
try:
|
|
109
|
-
self.
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
self._project_key = project_key
|
|
109
|
+
self._default_assignee = default_assignee
|
|
110
|
+
if not webhook_url:
|
|
111
|
+
logger.warning("No JIRA webhook URL provided. All issues will be posted to backlog.")
|
|
112
|
+
self._webhook_url = webhook_url
|
|
113
|
+
self._auth = self._authenticate(login, api_token)
|
|
114
|
+
try:
|
|
115
|
+
self.get_current_user()
|
|
116
|
+
except BadRequestError:
|
|
117
|
+
logger.warning("Failed to authenticate to Jira or incorrect project key.")
|
|
118
|
+
return False
|
|
119
|
+
self._issue_types = self.__get_issue_types()
|
|
120
|
+
return True
|
|
121
|
+
except Exception as ex:
|
|
122
|
+
logger.warning(f"Failed to configure Jira: {ex}")
|
|
112
123
|
return False
|
|
113
|
-
self._issue_types = self.__get_issue_types()
|
|
114
|
-
return True
|
|
115
124
|
|
|
116
125
|
def _authenticate(self, login, api_token) -> HTTPBasicAuth:
|
|
117
126
|
"""Function to authenticate the user with the provided username and API token.
|
|
@@ -886,6 +895,7 @@ class Jira:
|
|
|
886
895
|
return existing_ticket
|
|
887
896
|
|
|
888
897
|
assignee_id = None
|
|
898
|
+
assignee = assignee if assignee else self._default_assignee
|
|
889
899
|
if assignee:
|
|
890
900
|
try:
|
|
891
901
|
assignee_id = self.__get_assignee(assignee)
|
|
@@ -906,6 +916,7 @@ class Jira:
|
|
|
906
916
|
description=description,
|
|
907
917
|
assignee_id=assignee_id,
|
|
908
918
|
attachments=attachments,
|
|
919
|
+
labels=["bug_catcher"],
|
|
909
920
|
)
|
|
910
921
|
return response
|
|
911
922
|
except Exception as ex:
|
|
@@ -939,6 +950,13 @@ class Jira:
|
|
|
939
950
|
)
|
|
940
951
|
return existing_ticket
|
|
941
952
|
|
|
953
|
+
assignee_id = None
|
|
954
|
+
if self._default_assignee:
|
|
955
|
+
try:
|
|
956
|
+
assignee_id = self.__get_assignee(self._default_assignee)
|
|
957
|
+
except Exception as ex:
|
|
958
|
+
logger.info(f"Failed to get assignee {self._default_assignee} due to: {ex}")
|
|
959
|
+
|
|
942
960
|
description = self.__create_description_markup(
|
|
943
961
|
exc_type=exc_type,
|
|
944
962
|
exc_value=exc_value,
|
|
@@ -949,6 +967,7 @@ class Jira:
|
|
|
949
967
|
response = self.__create_new_ticket(
|
|
950
968
|
summary=summary,
|
|
951
969
|
description=description,
|
|
970
|
+
assignee_id=assignee_id,
|
|
952
971
|
labels=["fatal_error"],
|
|
953
972
|
)
|
|
954
973
|
return response
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|