def send_prime_suspect_email(latest_pipeline, streak, suspect_list): create_app_config() sender_user = get_app_config().cfg['SMTP_USER'] print("Setting up server") server = smtplib.SMTP(get_app_config().cfg['SMTP_SERVER']) print("Done setting up server\n") msg_body = "{} broke in GO at pipeline counter {}, and is currently at counter {}. If you pushed to this or any upstream recently, please investigate.".format( latest_pipeline.pipeline_name, streak.pass_counter+1, latest_pipeline.pipeline_counter) base_go_url = get_app_config().cfg['PUBLIC_GO_SERVER_URL'] base_dashboard_link = get_app_config().cfg['PUBLIC_DASH_URL'] insights_link = "{}insights/{}".format(base_dashboard_link, latest_pipeline.pipeline_name) go_overview_link = "{}tab/pipeline/history/{}".format(base_go_url, latest_pipeline.pipeline_name) msg_content = "<p>{}</p>" \ "<p>Link to insights: {}</p>" \ "<p>Link to GO Overview: {}</p>".format(msg_body, insights_link, go_overview_link) message = MIMEText(msg_content, 'html') recipients = get_suspects(suspect_list) message['From'] = 'Go.CD Dashboard <{}>'.format(sender_user) message['To'] = ', '.join(recipients) message['Subject'] = '{} broken in GO'.format(latest_pipeline.pipeline_name) msg_full = message.as_string() print("\n Sending email to: {}".format(recipients)) server.sendmail(sender_user, recipients, msg_full) print("\n Email sent!") print("\n -----MESSAGE FULL-----") print(msg_full) server.quit()
def init(application_cfg_path): app_config.create_app_config(application_cfg_path) pipeline_config.create_pipeline_config('./pipelines.json') go_client.create_go_client( app_config.get_app_config().cfg['GO_SERVER_URL'], (app_config.get_app_config().cfg['GO_SERVER_USER'], app_config.get_app_config().cfg['GO_SERVER_PASSWD']))
def setup_go_client(pargs): application_cfg_path = pargs.app_cfg app_config.create_app_config(application_cfg_path) file_source = pargs.file_source if file_source: app_config.get_app_config().cfg['GO_SERVER_URL'] = file_source go_client.go_client(app_config.get_app_config().cfg['GO_SERVER_URL'], (app_config.get_app_config().cfg['GO_SERVER_USER'], app_config.get_app_config().cfg['GO_SERVER_PASSWD']))
def setup_go_client(pargs): application_cfg_path = pargs.app_cfg app_config.create_app_config(application_cfg_path) file_source = pargs.file_source if file_source: app_config.get_app_config().cfg['GO_SERVER_URL'] = file_source go_client.go_client( app_config.get_app_config().cfg['GO_SERVER_URL'], (app_config.get_app_config().cfg['GO_SERVER_USER'], app_config.get_app_config().cfg['GO_SERVER_PASSWD']) )
def configure_from_args(pargs_dict): pipeline_cfg_path = pargs_dict['pipeline_cfg'] pipeline_config.create_pipeline_config(pipeline_cfg_path) application_cfg_path = pargs_dict['app_cfg'] app_config.create_app_config(application_cfg_path) db_port = pargs_dict['db_port'] if db_port: app_config.get_app_config().cfg['DB_PORT'] = db_port file_source = pargs_dict['file_source'] if file_source: app_config.get_app_config().cfg['GO_SERVER_URL'] = file_source return app_config.get_app_config().cfg['GO_SERVER_URL'], app_config.get_app_config().cfg['GO_SERVER_USER'], app_config.get_app_config().cfg['GO_SERVER_PASSWD'], app_config.get_app_config().cfg['DB_PORT']
def send_prime_suspect_email(latest_pipeline, streak, suspect_list): create_app_config() sender_user = get_app_config().cfg['SMTP_USER'] print("Setting up server") server = smtplib.SMTP(get_app_config().cfg['SMTP_SERVER']) print("Done setting up server\n") msg_body = ( "{} broke in GO at pipeline counter {}, and is currently at counter {}. " "If you pushed to this or any upstream recently, please investigate.". format(latest_pipeline.pipeline_name, streak.pass_counter + 1, latest_pipeline.pipeline_counter)) base_go_url = get_app_config().cfg['PUBLIC_GO_SERVER_URL'] base_dashboard_link = get_app_config().cfg['PUBLIC_DASH_URL'] insights_link = "{}insights/{}".format(base_dashboard_link, latest_pipeline.pipeline_name) go_overview_link = "{}tab/pipeline/history/{}".format( base_go_url, latest_pipeline.pipeline_name) msg_content = "<p>{}</p>" \ "<p>Link to insights: {}</p>" \ "<p>Link to GO Overview: {}</p>".format(msg_body, insights_link, go_overview_link) message = MIMEText(msg_content, 'html') recipients = get_suspects(suspect_list) message['From'] = 'Go.CD Dashboard <{}>'.format(sender_user) message['To'] = ', '.join(recipients) message['Subject'] = '{} broken in GO'.format( latest_pipeline.pipeline_name) msg_full = message.as_string() print("\n Sending email to: {}".format(recipients)) server.sendmail(sender_user, recipients, msg_full) print("\n Email sent!") print("\n -----MESSAGE FULL-----") print(msg_full) server.quit()