예제 #1
0
    def get_pipelines(self):
        current_time = int(round(time.time() * 1000))
        if current_time - self.latest_synced > cache_age:
            project = get_cctray_status()
            self.pipelines = project.select('failing')
            self.latest_synced = current_time

        return self.pipelines
예제 #2
0
파일: app.py 프로젝트: hedmanw/gocddash
def dashboard():
    which = request.args.get('which', 'failing')
    project = get_cctray_status()
    progress_bar_data = get_progress_bar_data(project)
    groups = request.cookies.get(
        'checked_pipeline_groups_cookie', '').split(',')

    pipelines = project.select(
        which, groups=groups, group_map=group_of_pipeline)

    # previous_pipelines = get_cache().get_pipelines()
    finished_pipelines = []
    if which == 'failing':
        pipeline_names = [pipeline.name for pipeline in pipelines]
        # finished_pipelines = [pipeline for pipeline in previous_pipelines if pipeline.name not in pipeline_names]
        # new_failing_pipelines = [pipeline for pipeline in pipelines if pipeline not in previous_pipelines]
        # if new_failing_pipelines:
        #     for pipeline in new_failing_pipelines:
        #         finished_pipelines.append(pipeline)

    all_pipelines = project.select('all')
    unwanted_pipelines = []
    for name, group in group_of_pipeline.items():
        if group not in groups:
            unwanted_pipelines.append(name)

    finished_pipelines = [pipeline for pipeline in all_pipelines if
                          pipeline in finished_pipelines and pipeline.name not in unwanted_pipelines]

    for pipeline in pipelines:
        pipeline_name = pipeline.name
        message, whom = pipeline_is_paused(pipeline_name)
        if message:
            pipeline.status = 'Paused'
            pipeline.messages['PausedCause'].add(message)
        if whom:
            pipeline.messages['PausedBy'].add(whom)

    synced_pipelines = dict()
    for pipeline_head in get_pipeline_heads():
        synced_pipelines[pipeline_head.pipeline_name] = pipeline_head

    loose_claims = dict()  # Loose meaning that the pipelines are not synced - but they can still be claimed.
    for claim in get_claims_for_unsynced_pipelines():
        loose_claims[claim.pipeline_name] = claim

    return render_template('index.html',
                           go_server_url=app.config['PUBLIC_GO_SERVER_URL'],
                           pipelines=pipelines,
                           theme=get_bootstrap_theme(),
                           cols=app.config['PIPELINE_COLUMNS'],
                           now=datetime.now(),
                           footer=get_footer(),
                           synced_pipelines=synced_pipelines,
                           unsynced_claims=loose_claims,
                           progress_bar_data=progress_bar_data,
                           application_root=app.config['APPLICATION_ROOT'],
                           finished_pipelines=finished_pipelines)
예제 #3
0
def dashboard():
    which = request.args.get('which', 'failing')
    project = get_cctray_status()
    progress_bar_data = get_progress_bar_data(project)
    groups = request.cookies.get('checked_pipeline_groups_cookie', ','.join(
        set(group_of_pipeline.values()))).split(',')

    pipelines = project.select(which,
                               groups=groups,
                               group_map=group_of_pipeline)

    unwanted_pipelines = []
    for name, group in group_of_pipeline.items():
        if group not in groups:
            unwanted_pipelines.append(name)

    for pipeline in pipelines:
        pipeline_name = pipeline.name
        message, whom = pipeline_is_paused(pipeline_name)
        if message:
            pipeline.status = 'Paused'
            pipeline.messages['PausedCause'].add(message)
        if whom:
            pipeline.messages['PausedBy'].add(whom)

    synced_pipelines = dict()
    #    for pipeline_head in get_connection().get_synced_pipeline_heads():
    for pipeline_head in get_pipeline_heads():
        synced_pipelines[pipeline_head.pipeline_name] = pipeline_head

    loose_claims = dict(
    )  # Loose meaning that the pipelines are not synced - but they can still be claimed.
    for claim in get_claims_for_unsynced_pipelines():
        loose_claims[claim.pipeline_name] = claim

    return render_template('index.html',
                           go_server_url=app.config['PUBLIC_GO_SERVER_URL'],
                           pipelines=pipelines,
                           theme=get_bootstrap_theme(),
                           cols=app.config['PIPELINE_COLUMNS'],
                           now=datetime.now(),
                           footer=get_footer(),
                           synced_pipelines=synced_pipelines,
                           unsynced_claims=loose_claims,
                           progress_bar_data=progress_bar_data,
                           application_root=app.config['APPLICATION_ROOT'])
예제 #4
0
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)
예제 #5
0
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)