def build_email_notifications(pipeline_name): latest_pipeline = get_pipeline_head(pipeline_name) if not latest_pipeline.is_success() and not get_connection().email_notification_sent_for_current_streak( pipeline_name): print("\n -----SENDING EMAILS FOR {}-----".format(pipeline_name)) streak = get_latest_failure_streak(pipeline_name) perpetrator_data = get_git_comparison(pipeline_name, streak.pass_counter+1, streak.pass_counter, "") try: send_prime_suspect_email(latest_pipeline, streak, perpetrator_data) create_email_notification_sent(pipeline_name, streak.pass_counter+1) except Exception: print("Could not send email for pipeline " + pipeline_name)
def build_email_notifications(pipeline_name): latest_pipeline = get_pipeline_head(pipeline_name) if not latest_pipeline.is_success() and not get_connection().email_notification_sent_for_current_streak( pipeline_name): print("\n -----SENDING EMAILS FOR {}-----".format(pipeline_name)) streak = get_latest_failure_streak(pipeline_name) perpetrator_data = get_git_comparison(pipeline_name, streak.pass_counter + 1, streak.pass_counter, "") try: send_prime_suspect_email(latest_pipeline, streak, perpetrator_data) create_email_notification_sent(pipeline_name, streak.pass_counter + 1) except Exception as error: # TODO: Narrow down to expected exception classes. We don't want to hide bugs e.g. NameError. print("Could not send email for pipeline " + pipeline_name) print(error)
def build_email_notifications(pipeline_name): latest_pipeline = get_pipeline_head(pipeline_name) if not latest_pipeline.is_success() and not get_connection( ).email_notification_sent_for_current_streak(pipeline_name): print("\n -----SENDING EMAILS FOR {}-----".format(pipeline_name)) streak = get_latest_failure_streak(pipeline_name) perpetrator_data = get_git_comparison(pipeline_name, streak.pass_counter + 1, streak.pass_counter, "") try: send_prime_suspect_email(latest_pipeline, streak, perpetrator_data) create_email_notification_sent(pipeline_name, streak.pass_counter + 1) except Exception as error: # TODO: Narrow down to expected exception classes. We don't want to hide bugs e.g. NameError. print("Could not send email for pipeline " + pipeline_name) print(error)
def insights(pipeline_name): current_stage = get_current_stage(pipeline_name) if current_stage is None: abort( 500, "Database error. Have you tried syncing some pipelines " "using gocddash_sync.py? Current_stage is None.") current_status = pipeline_status.create_stage_info(current_stage) last_stage = get_previous_stage(current_stage) previous_status = pipeline_status.create_stage_info(last_stage) latest_passing_stage = get_latest_passing_stage(pipeline_name) stage_name_index = (get_connection().get_stage_order(pipeline_name)).index( current_stage.stage_name) git_history = [] perpetrator_data = [] if not current_stage.is_success(): if latest_passing_stage is None: latest_passing_stage = get_first_synced_stage(pipeline_name) if not current_stage.pipeline_counter - latest_passing_stage.pipeline_counter == 1: perpetrator_data = get_git_comparison( pipeline_name, latest_passing_stage.pipeline_counter + 1, latest_passing_stage.pipeline_counter, app.config['PREFERRED_UPSTREAM']) git_history = get_git_comparison(pipeline_name, current_stage.pipeline_counter, latest_passing_stage.pipeline_counter, app.config['PREFERRED_UPSTREAM']) base_url = app.config['PUBLIC_GO_SERVER_URL'] rerun_link = base_url + "pipelines/{}/{}/{}/{}".format( current_stage.pipeline_name, current_stage.pipeline_counter, current_stage.stage_name, current_stage.stage_counter) job_to_display = get_job_to_display(current_stage.stage_id) if job_to_display: log_link = base_url + "tab/build/detail/{}/{}/{}/{}/{}#tab-tests".format( current_stage.pipeline_name, current_stage.pipeline_counter, current_stage.stage_name, current_stage.stage_counter, job_to_display.job_name) else: log_link = 'FIX_THIS' main_pipeline_link = base_url + "tab/pipeline/history/{}".format( current_stage.pipeline_name) comparison_link = base_url + "compare/{}/{}/with/{}".format( current_stage.pipeline_name, current_stage.pipeline_counter, latest_passing_stage.pipeline_counter) dash_status = get_cctray_status() recommendation, last_claim = failure_tip.get_failure_tip( current_status, previous_status, latest_passing_stage.pipeline_counter) template = render_template( 'insights.html', go_server_url=app.config['PUBLIC_GO_SERVER_URL'], now=datetime.now(), theme=get_bootstrap_theme(), footer=get_footer(), current_status=current_status, git_history=git_history, rerun_link=rerun_link, comparison_link=comparison_link, live_info=dash_status.pipelines[pipeline_name], latest_passing_stage=latest_passing_stage, previous_status=previous_status, recommendation=recommendation, last_claim=last_claim, log_link=log_link, main_pipeline_link=main_pipeline_link, stage_name_index=stage_name_index, application_root=app.config['APPLICATION_ROOT'], username=app.config['GO_SERVER_USER'], passwd=app.config['GO_SERVER_PASSWD'], rerun_token=app.config['RERUN_TOKEN'], perpretrator_data=perpetrator_data) return make_response(template)
def insights(pipeline_name): current_stage = get_current_stage(pipeline_name) if current_stage is None: abort(500, "Database error. Have you tried syncing some pipelines " "using gocddash_sync.py? Current_stage is None.") current_status = pipeline_status.create_stage_info(current_stage) last_stage = get_previous_stage(current_stage) previous_status = pipeline_status.create_stage_info(last_stage) latest_passing_stage = get_latest_passing_stage(pipeline_name) stage_name_index = (get_connection().get_stage_order(pipeline_name)).index(current_stage.stage_name) git_history = [] perpetrator_data = [] if not current_stage.is_success(): if latest_passing_stage is None: latest_passing_stage = get_first_synced_stage(pipeline_name) if not current_stage.pipeline_counter - latest_passing_stage.pipeline_counter == 1: perpetrator_data = get_git_comparison(pipeline_name, latest_passing_stage.pipeline_counter + 1, latest_passing_stage.pipeline_counter, app.config['PREFERRED_UPSTREAM']) git_history = get_git_comparison(pipeline_name, current_stage.pipeline_counter, latest_passing_stage.pipeline_counter, app.config['PREFERRED_UPSTREAM']) base_url = app.config['PUBLIC_GO_SERVER_URL'] rerun_link = base_url + "pipelines/{}/{}/{}/{}".format(current_stage.pipeline_name, current_stage.pipeline_counter, current_stage.stage_name, current_stage.stage_counter) job_to_display = get_job_to_display(current_stage.stage_id) if job_to_display: log_link = base_url + "tab/build/detail/{}/{}/{}/{}/{}#tab-tests".format( current_stage.pipeline_name, current_stage.pipeline_counter, current_stage.stage_name, current_stage.stage_counter, job_to_display.job_name) else: log_link = 'FIX_THIS' main_pipeline_link = base_url + "tab/pipeline/history/{}".format(current_stage.pipeline_name) comparison_link = base_url + "compare/{}/{}/with/{}".format(current_stage.pipeline_name, current_stage.pipeline_counter, latest_passing_stage.pipeline_counter) dash_status = get_cctray_status() recommendation, last_claim = failure_tip.get_failure_tip(current_status, previous_status, latest_passing_stage.pipeline_counter) template = render_template( 'insights.html', go_server_url=app.config['PUBLIC_GO_SERVER_URL'], now=datetime.now(), theme=get_bootstrap_theme(), footer=get_footer(), current_status=current_status, git_history=git_history, rerun_link=rerun_link, comparison_link=comparison_link, live_info=dash_status.pipelines[pipeline_name], latest_passing_stage=latest_passing_stage, previous_status=previous_status, recommendation=recommendation, last_claim=last_claim, log_link=log_link, main_pipeline_link=main_pipeline_link, stage_name_index=stage_name_index, application_root=app.config['APPLICATION_ROOT'], username=app.config['GO_SERVER_USER'], passwd=app.config['GO_SERVER_PASSWD'], rerun_token=app.config['RERUN_TOKEN'], perpretrator_data=perpetrator_data ) return make_response(template)