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()
Beispiel #2
0
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']))
Beispiel #3
0
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']))
Beispiel #4
0
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'])
    )
Beispiel #5
0
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']
Beispiel #6
0
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()
Beispiel #7
0
            self.nodes = [(prefix, json_structure)]

    @classmethod
    def json_nodes_list(cls, json_structure, prefix=None):
        result = []
        for elm in json_structure:
            result.extend(cls(elm, prefix).nodes)
        return result

    @classmethod
    def json_nodes_dict(cls, json_structure, prefix=None):
        result = []
        for key, value in json_structure.items():
            if not prefix:
                new_prefix = key
            else:
                new_prefix = prefix + '.' + key
            result.extend(cls(value, new_prefix).nodes)
        return result


if __name__ == '__main__':
    setup_go_client(parse_args())
    go = go_client.go_client()
    db = data_access.get_connection(app_config.get_app_config().cfg['DB_PATH'])
    controller = SyncController(db, go)
    log("Starting synchronization.")
    controller.sync()
    log("Synchronization finished.")
    log('Done!')
Beispiel #8
0
            self.nodes = [(prefix, json_structure)]

    @classmethod
    def json_nodes_list(cls, json_structure, prefix=None):
        result = []
        for elm in json_structure:
            result.extend(cls(elm, prefix).nodes)
        return result

    @classmethod
    def json_nodes_dict(cls, json_structure, prefix=None):
        result = []
        for key, value in json_structure.items():
            if not prefix:
                new_prefix = key
            else:
                new_prefix = prefix + '.' + key
            result.extend(cls(value, new_prefix).nodes)
        return result


if __name__ == '__main__':
    setup_go_client(parse_args())
    go = go_client.go_client()
    db = data_access.get_connection(app_config.get_app_config().cfg['DB_PATH'])
    controller = SyncController(db, go)
    log("Starting synchronization.")
    controller.sync()
    log("Synchronization finished.")
    log('Done!')