Esempio n. 1
0
def get_all_builds(request):
    name = request.GET.get('name')
    branch = request.GET.get('branch')
    index = int(request.GET.get('page_index', '1'))
    size = int(request.GET.get('page_size', common.DEFAULT_BUILD_SIZE))
    builds = builds_helper.get_builds(request,
                                      name=name,
                                      branch=branch,
                                      pageIndex=index,
                                      pageSize=size)
    scm_url = systems_helper.get_scm_url(request)
    current_build_id = request.GET.get('current_build_id', None)
    current_build = None
    if current_build_id:
        current_build = builds_helper.get_build(request, current_build_id)

    html = render_to_string(
        'builds/pick_a_build.tmpl', {
            "builds": builds,
            "current_build": current_build,
            "scm_url": scm_url,
            "buildName": name,
            "branch": branch,
            "pageIndex": index,
            "pageSize": common.DEFAULT_BUILD_SIZE,
            "disablePrevious": index <= 1,
            "disableNext": len(builds) < common.DEFAULT_BUILD_SIZE,
        })
    return HttpResponse(html)
Esempio n. 2
0
def get_all_builds(request):
    name = request.GET.get('name')
    branch = request.GET.get('branch')
    index = int(request.GET.get('page_index', '1'))
    size = int(request.GET.get('page_size', common.DEFAULT_BUILD_SIZE))
    builds = builds_helper.get_builds(request, name=name, branch=branch, pageIndex=index,
                                      pageSize=size)
    scm_url = systems_helper.get_scm_url(request)
    current_build_id = request.GET.get('current_build_id', None)
    current_build = None
    if current_build_id:
        current_build = builds_helper.get_build(request, current_build_id)

    html = render_to_string('builds/pick_a_build.tmpl', {
        "builds": builds,
        "current_build": current_build,
        "scm_url": scm_url,
        "buildName": name,
        "branch": branch,
        "pageIndex": index,
        "pageSize": common.DEFAULT_BUILD_SIZE,
        "disablePrevious": index <= 1,
        "disableNext": len(builds) < common.DEFAULT_BUILD_SIZE,
    })
    return HttpResponse(html)
Esempio n. 3
0
def list_builds(request, name):
    index = int(request.GET.get('page_index', '1'))
    size = int(request.GET.get('page_size', common.DEFAULT_BUILD_SIZE))
    builds = builds_helper.get_builds(request, name=name, pageIndex=index, pageSize=size)
    return render(request, 'builds/builds.html', {
        'build_name': name,
        'builds': builds,
        "pageIndex": index,
        "pageSize": common.DEFAULT_BUILD_SIZE,
        "disablePrevious": index <= 1,
        "disableNext": len(builds) < common.DEFAULT_BUILD_SIZE,
    })
Esempio n. 4
0
def list_builds(request, name):
    index = int(request.GET.get('page_index', '1'))
    size = int(request.GET.get('page_size', common.DEFAULT_BUILD_SIZE))
    builds = builds_helper.get_builds(request,
                                      name=name,
                                      pageIndex=index,
                                      pageSize=size)
    return render(
        request, 'builds/builds.html', {
            'build_name': name,
            'builds': builds,
            "pageIndex": index,
            "pageSize": common.DEFAULT_BUILD_SIZE,
            "disablePrevious": index <= 1,
            "disableNext": len(builds) < common.DEFAULT_BUILD_SIZE,
        })
Esempio n. 5
0
def _get_commit_info(request, commit, repo=None, branch='master'):
    # We try teletraan for commit info first, if not found, try backend
    builds = builds_helper.get_builds(request, commit=commit)
    if builds:
        build = builds[0]
        return build['repo'], build['branch'], build['commitDate']

    if not repo:
        # Without repo, we can not call github api, return None
        log.error("Repo is expected when query based on commit which has no build")
        return None, None, None

    try:
        commit_info = builds_helper.get_commit(request, repo, commit)
        return repo, branch, commit_info['date']
    except:
        log.error(traceback.format_exc())
        return None, None, None
Esempio n. 6
0
def deploy_commit(request, name, stage, commit):
    env = environs_helper.get_env_by_stage(request, name, stage)
    builds = builds_helper.get_builds(request, commit=commit)
    current_build = None
    if env.get('deployId'):
        deploy = deploys_helper.get(request, env['deployId'])
        current_build = builds_helper.get_build(request, deploy['buildId'])
    scm_url = systems_helper.get_scm_url(request)

    html = render_to_string('deploys/deploy_build.html', {
        "env": env,
        "builds": builds,
        "current_build": current_build,
        "scm_url": scm_url,
        "buildName": env.get('buildName'),
        "branch": env.get('branch'),
        "csrf_token": get_token(request),
    })
    return HttpResponse(html)
Esempio n. 7
0
def get_builds(request, name, stage):
    env = environs_helper.get_env_by_stage(request, name, stage)
    env_promote = environs_helper.get_env_promotes_config(request, name, stage)

    show_lock = False
    if env_promote['type'] == 'AUTO' and env_promote['predStage'] and \
            env_promote['predStage'] == environs_helper.BUILD_STAGE:
        show_lock = True

    if 'buildName' not in env and not env['buildName']:
        html = render_to_string('builds/simple_builds.tmpl', {
            "builds": [],
            "env": env,
            "show_lock": show_lock,
        })
        return HttpResponse(html)

    current_publish_date = 0
    if 'deployId' in env and env['deployId']:
        deploy = deploys_helper.get(request, env['deployId'])
        build = builds_helper.get_build(request, deploy['buildId'])
        current_publish_date = build['publishDate']

    # return only the new builds
    index = int(request.GET.get('page_index', '1'))
    size = int(request.GET.get('page_size', common.DEFAULT_BUILD_SIZE))
    builds = builds_helper.get_builds(request,
                                      name=env['buildName'],
                                      pageIndex=index,
                                      pageSize=size)
    new_builds = []
    for build in builds:
        if build['publishDate'] > current_publish_date:
            new_builds.append(build)

    html = render_to_string(
        'builds/simple_builds.tmpl', {
            "builds": new_builds,
            "current_publish_date": current_publish_date,
            "env": env,
            "show_lock": show_lock,
        })
    return HttpResponse(html)
Esempio n. 8
0
def _get_commit_info(request, commit, repo=None, branch='master'):
    # We try teletraan for commit info first, if not found, try backend
    builds = builds_helper.get_builds(request, commit=commit)
    if builds:
        build = builds[0]
        return build['repo'], build['branch'], build['commitDate']

    if not repo:
        # Without repo, we can not call github api, return None
        log.error(
            "Repo is expected when query based on commit which has no build")
        return None, None, None

    try:
        commit_info = builds_helper.get_commit(request, repo, commit)
        return repo, branch, commit_info['date']
    except:
        log.error(traceback.format_exc())
        return None, None, None
Esempio n. 9
0
def deploy_commit(request, name, stage, commit):
    env = environs_helper.get_env_by_stage(request, name, stage)
    builds = builds_helper.get_builds(request, commit=commit)
    current_build = None
    if env.get('deployId'):
        deploy = deploys_helper.get(request, env['deployId'])
        current_build = builds_helper.get_build(request, deploy['buildId'])
    scm_url = systems_helper.get_scm_url(request)

    html = render_to_string(
        'deploys/deploy_build.html', {
            "env": env,
            "builds": builds,
            "current_build": current_build,
            "scm_url": scm_url,
            "buildName": env.get('buildName'),
            "branch": env.get('branch'),
            "csrf_token": get_token(request),
        })
    return HttpResponse(html)
Esempio n. 10
0
def get_builds(request, name, stage):
    env = environs_helper.get_env_by_stage(request, name, stage)
    env_promote = environs_helper.get_env_promotes_config(request, name, stage)

    show_lock = False
    if env_promote['type'] == 'AUTO' and env_promote['predStage'] and \
            env_promote['predStage'] == environs_helper.BUILD_STAGE:
        show_lock = True

    if 'buildName' not in env and not env['buildName']:
        html = render_to_string('builds/simple_builds.tmpl', {
            "builds": [],
            "env": env,
            "show_lock": show_lock,
        })
        return HttpResponse(html)

    current_publish_date = 0
    if 'deployId' in env and env['deployId']:
        deploy = deploys_helper.get(request, env['deployId'])
        build = builds_helper.get_build(request, deploy['buildId'])
        current_publish_date = build['publishDate']

    # return only the new builds
    index = int(request.GET.get('page_index', '1'))
    size = int(request.GET.get('page_size', common.DEFAULT_BUILD_SIZE))
    builds = builds_helper.get_builds(request, name=env['buildName'], pageIndex=index,
                                      pageSize=size)
    new_builds = []
    for build in builds:
        if build['publishDate'] > current_publish_date:
            new_builds.append(build)

    html = render_to_string('builds/simple_builds.tmpl', {
        "builds": new_builds,
        "current_publish_date": current_publish_date,
        "env": env,
        "show_lock": show_lock,
    })
    return HttpResponse(html)
Esempio n. 11
0
def search_commit(request, commit):
    builds = builds_helper.get_builds(request, commit=commit)
    return render(request, 'builds/builds_by_commit.html', {
        'commit': commit,
        'builds': builds,
    })
Esempio n. 12
0
def search_commit(request, commit):
    builds = builds_helper.get_builds(request, commit=commit)
    return render(request, 'builds/builds_by_commit.html', {
        'commit': commit,
        'builds': builds,
    })