From f193de11dc7ca7da5da2ee6728f43ef6de7dd7a9 Mon Sep 17 00:00:00 2001 From: Nicolas Schweitzer Date: Fri, 13 Dec 2024 18:05:47 +0100 Subject: [PATCH] fix(notify): Handle case with undefined variable --- tasks/libs/notify/utils.py | 2 +- tasks/unit_tests/notify_tests.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/libs/notify/utils.py b/tasks/libs/notify/utils.py index d1d803f1b2d64..31066152f95c0 100644 --- a/tasks/libs/notify/utils.py +++ b/tasks/libs/notify/utils.py @@ -65,7 +65,7 @@ def notification_type(): """ Return the type of notification to send (related to the type of pipeline, amongst 'deploy', 'trigger' and 'merge') """ - if os.environ['DEPLOY_AGENT'] == 'true': + if os.environ.get('DEPLOY_AGENT', '') == 'true': return 'deploy' elif os.environ['CI_PIPELINE_SOURCE'] != 'push': return 'trigger' diff --git a/tasks/unit_tests/notify_tests.py b/tasks/unit_tests/notify_tests.py index 87c93d579c77d..2210da2132149 100644 --- a/tasks/unit_tests/notify_tests.py +++ b/tasks/unit_tests/notify_tests.py @@ -31,7 +31,7 @@ def get_github_slack_map(): class TestSendMessage(unittest.TestCase): - @patch.dict('os.environ', {'DEPLOY_AGENT': 'false', 'CI_PIPELINE_SOURCE': 'push', 'CI_PIPELINE_ID': '42'}) + @patch.dict('os.environ', {'CI_PIPELINE_SOURCE': 'push', 'CI_PIPELINE_ID': '42'}) @patch('tasks.libs.pipeline.notifications.get_pr_from_commit', new=MagicMock(return_value="")) @patch('builtins.print') @patch('tasks.libs.ciproviders.gitlab_api.get_gitlab_api')