Skip to content

Commit

Permalink
fix(notify): Handle case with undefined variable
Browse files Browse the repository at this point in the history
  • Loading branch information
chouetz committed Dec 19, 2024
1 parent 9056fb7 commit f193de1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tasks/libs/notify/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion tasks/unit_tests/notify_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit f193de1

Please sign in to comment.