Skip to content
Snippets Groups Projects
Commit 29357b77 authored by Charlotte Hausman's avatar Charlotte Hausman
Browse files

Merge remote-tracking branch 'origin/main' into catch_up_with_main_2.8.2

# Conflicts:
#	.gitlab-ci.yml
#	apps/cli/utilities/contacts_wrest/setup.py
#	ci/bin/generate-yaml.py
#	ci/build.template.yml
#	ci/push.template.yml
#	ci/unit-test.template.yml
#	shared/schema/setup.py
#	shared/workspaces/setup.py
parents 677367ce 2b3ffc8d
No related branches found
No related tags found
2 merge requests!1452Merge 2.8.2 to main,!1408catch up with 2.8.1.1, pin zope.sqlalchemy to 2.0
......@@ -127,9 +127,9 @@ def main(argv):
- apps/cli/executables/go/**/*"""
else:
if deploy_env == "test":
rule = "$CI_COMMIT_TAG =~ /^end-of-sprint-[0-9]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/"
rule = "$CI_COMMIT_TAG =~ /^end-of-sprint-[0-9]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0.9]+-rc[0-9]+/"
if deploy_env == "prod":
rule = "$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+$/"
rule = "$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+$/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/"
write_global_rule(rule=rule)
go_changes = get_list_of_go_modules()
......
......@@ -32,7 +32,7 @@
DEPLOY_ENV: "test"
changes:
- ${PATH_PREFIX}${SERVICE_NAME}/**/*
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/'
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0.9]+-rc[0-9]+/'
variables:
IMAGE_TAG: $CI_COMMIT_TAG
VERSION: $CI_COMMIT_TAG
......@@ -40,7 +40,7 @@
DEPLOY_ENV: "test"
changes:
- ${PATH_PREFIX}${SERVICE_NAME}/**/*
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+$/'
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+$/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/'
variables:
IMAGE_TAG: $CI_COMMIT_TAG
VERSION: $CI_COMMIT_TAG
......
......@@ -10,18 +10,18 @@
IMAGE_TAG: $CI_COMMIT_BRANCH
changes:
- ${PATH_PREFIX}${SERVICE_NAME}/**/*
# For pipeline testing only!
# - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
# variables:
# IMAGE_TAG: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
# changes:
# - ${PATH_PREFIX}${SERVICE_NAME}/**/*
- if: '$CI_COMMIT_TAG =~ /^end-of-sprint-[0-9]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/'
# For pipeline testing only!
# - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
# variables:
# IMAGE_TAG: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
# changes:
# - ${PATH_PREFIX}${SERVICE_NAME}/**/*
- if: '$CI_COMMIT_TAG =~ /^end-of-sprint-[0-9]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0.9]+-rc[0-9]+/'
variables:
IMAGE_TAG: $CI_COMMIT_TAG
changes:
- ${PATH_PREFIX}${SERVICE_NAME}/**/*
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+$/'
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+$/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/'
variables:
IMAGE_TAG: $CI_COMMIT_TAG
changes:
......
......@@ -20,12 +20,12 @@
IMAGE_TAG: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
changes:
- ${PATH_PREFIX}${SERVICE_NAME}/**/*
- if: '$CI_COMMIT_TAG =~ /^end-of-sprint-[0-9]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/'
- if: '$CI_COMMIT_TAG =~ /^end-of-sprint-[0-9]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0.9]+-rc[0-9]+/'
variables:
IMAGE_TAG: $CI_COMMIT_TAG
changes:
- ${PATH_PREFIX}${SERVICE_NAME}/**/*
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+$/'
- if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+$/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/'
variables:
IMAGE_TAG: $CI_COMMIT_TAG
changes:
......
......@@ -26,6 +26,7 @@ import smtplib
from typing import Dict
import requests
from email_validator import validate_email, EmailNotValidError
from pycapo import CapoConfig
from workspaces.notification.services.interfaces import (
......@@ -70,38 +71,50 @@ class NotificationService(NotificationServiceIF):
if isinstance(parameters["destination_email"], list):
receiver_emails = parameters["destination_email"]
else:
receiver_emails = [parameters["destination_email"]]
# sometimes the list gets passed in as a string, split it if needed and strip extra spaces
receiver_emails = [address.strip() for address in parameters["destination_email"].split(",")]
# Let's not send emails into the void
if not receiver_emails:
return "No PI email found."
logger.info(f">> In send_email, sending email to: {receiver_emails}")
logger.info(f">> The parameters are: {parameters}")
template = self.info.lookup_template(template_name)
# verify email addresses are valid. Drop invalid addresses
for address in receiver_emails:
try:
validate_email(address)
except EmailNotValidError as e:
logger.info(f"Invalid email address {address} found, removing from receivers list.")
receiver_emails.remove(address)
if template is None:
logger.info("No template '" + template_name + "' found.")
if len(receiver_emails) > 0:
logger.info(f">> In send_email, sending email to: {receiver_emails}")
logger.info(f">> The parameters are: {parameters}")
template = self.info.lookup_template(template_name)
file = template.render(parameters)
if template is None:
logger.info("No template '" + template_name + "' found.")
# Load the headers and email content from the template
msg = email.message_from_bytes(file.content)
file = template.render(parameters)
# Attach the 'from', 'to', and 'cc' headers if they weren't set in the template
if msg["From"] is None:
msg["From"] = sender_email
# Load the headers and email content from the template
msg = email.message_from_bytes(file.content)
if msg["To"] is None:
msg["To"] = ', '.join(receiver_emails)
# Attach the 'from', 'to', and 'cc' headers if they weren't set in the template
if msg["From"] is None:
msg["From"] = sender_email
if msg["Cc"] is None and "cc_email" in parameters and parameters["cc_email"] is not None:
if isinstance(parameters["cc_email"], list):
msg["Cc"] = ', '.join(parameters["cc_email"])
else:
msg["Cc"] = parameters["cc_email"]
if msg["To"] is None:
msg["To"] = ", ".join(receiver_emails)
with smtplib.SMTP(smtp_server) as server:
r = server.send_message(msg)
if msg["Cc"] is None and "cc_email" in parameters and parameters["cc_email"] is not None:
if isinstance(parameters["cc_email"], list):
msg["Cc"] = ", ".join(parameters["cc_email"])
else:
msg["Cc"] = parameters["cc_email"]
return r
with smtplib.SMTP(smtp_server) as server:
r = server.send_message(msg)
return r
else:
logger.info("No valid email addresses provided. Skipping sending mail.")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment