def disconnect(self, close_code): branch_tag = self.config.repo_model if self.release_name == self.release_desc else self.branch_tag try: if len(self.host_list) == 0: status = '所有主机均部署失败,主机:{}'.format(', '.join(self.host_list)) elif len(self.host_fail) == 0: status = '所有主机均部署成功,主机:{}'.format(', '.join(self.host_list)) else: status = '主机:{} 部署成功;主机:{} 部署失败'.format( ', '.join(self.host_list), ', '.join(self.host_fail)) d_type = '回滚' if self.d_type == 'rollback' else '部署' paras = (self.config.project.project_name, self.config.project.get_project_env_display(), d_type, branch_tag, self.release_name, self.scope['user'].username, status) if self.config.to_mail: deploy_mail(self.config.to_mail, self.config.cc_mail, *paras) if self.config.wx_notice: deploy_wx(*paras) except Exception as e: deploy_logger.error('部署通知操作失败!{}'.format(e)) finally: if '<p style="color: #FF0000">所有主机均部署失败!退出部署流程!</p>' in self.deploy_results: self.deploy_results = self.deploy_results[:self.deploy_results.index( '<p style="color: #FF0000">所有主机均部署失败!退出部署流程!</p>') + 1] deploy_log.delay(project_config=self.config, deploy_user=self.scope['user'], d_type=self.d_type, branch_tag=branch_tag, release_name=self.release_name, release_desc=self.release_desc, result=self.deploy_results)
def disconnect(self, close_code): if '<p style="color: #FF0000">所有主机均部署失败!退出部署流程!</p>' in self.deploy_results: self.deploy_results = self.deploy_results[:self.deploy_results.index( '<p style="color: #FF0000">所有主机均部署失败!退出部署流程!</p>') + 1] deploy_log.delay(project_config=self.config, deploy_user=self.scope['user'], d_type=self.d_type, branch_tag=self.branch_tag, release_name=self.release_name, release_desc=self.release_desc, result=self.deploy_results)