diff --git a/spug_api/apps/deploy/utils.py b/spug_api/apps/deploy/utils.py index c7763e27..d24c4237 100644 --- a/spug_api/apps/deploy/utils.py +++ b/spug_api/apps/deploy/utils.py @@ -193,6 +193,7 @@ def __init__(self, rds, token, r_id): @staticmethod def send_deploy_notify(req): rst_notify = json.loads(req.deploy.rst_notify) + host_ids = json.loads(req.host_ids) if rst_notify['mode'] != '0' and rst_notify.get('value'): extra = json.loads(req.extra) if req.deploy.extend == '1': @@ -203,13 +204,15 @@ def send_deploy_notify(req): version = extra1 else: version = extra[0] + hosts = [{'id': x.id, 'name': x.name} for x in Host.objects.filter(id__in=host_ids)] if rst_notify['mode'] == '1': color, text = ('#8ece60', '成功') if req.status == '3' else ('#f90202', '失败') texts = [ '## %s ## ' % '发布结果通知', f'**应用名称:** {req.deploy.app.name} ', - f'**发布环境:** {req.deploy.env.name} ', f'**应用版本:** {version} ', + f'**发布环境:** {req.deploy.env.name} ', + f'**发布主机:** {",".join(x["name"] for x in hosts)} ', f'**发布结果:** {text}', f'**发布时间:** {human_datetime()} ', '> 来自 Spug运维平台' @@ -230,6 +233,7 @@ def send_deploy_notify(req): 'env_id': req.deploy.env_id, 'env_name': req.deploy.env.name, 'version': version, + 'targets': hosts, 'is_success': req.status == '3', 'deploy_at': human_datetime() }