Example #1
0
def get_new_commits(request, name, stage):
    env = environs_helper.get_env_by_stage(request, name, stage)
    current_deploy = deploys_helper.get(request, env['deployId'])
    current_build = builds_helper.get_build(request, current_deploy['buildId'])
    startSha = current_build['commit']
    repo = current_build['repo']
    scm_url = systems_helper.get_scm_url(request)
    diffUrl = "%s/%s/compare/%s...%s" % (scm_url, repo, startSha, startSha)
    last_deploy = common.get_last_completed_deploy(request, env)
    if not last_deploy:
        return render(request, 'deploys/deploy_commits.html', {
            "env": env,
            "title": "No previous deploy found!",
            "startSha": startSha,
            "endSha": startSha,
            "repo": repo,
            "diffUrl": diffUrl,
        })

    last_build = builds_helper.get_build(request, last_deploy['buildId'])
    endSha = last_build['commit']
    diffUrl = "%s/%s/compare/%s...%s" % (scm_url, repo, endSha, startSha)
    return render(request, 'deploys/deploy_commits.html', {
        "env": env,
        "startSha": startSha,
        "endSha": endSha,
        "repo": repo,
        "title": "Commits since last deploy",
        "diffUrl": diffUrl,
    })
Example #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_and_tags(request, name=name, branch=branch, pageIndex=index,
                                      pageSize=size)
    scm_url = systems_helper.get_scm_url(request)
    deploy_state = None
    current_build_id = request.GET.get('current_build_id', None)
    override_policy = request.GET.get('override_policy')
    deploy_id = request.GET.get('deploy_id')
    current_build = None
    if current_build_id:
        current_build = builds_helper.get_build_and_tag(request, current_build_id)
        current_build = current_build.get('build')
    if deploy_id:
        deploy_config = deploys_helper.get(request, deploy_id)
        if deploy_config:
            deploy_state = deploy_config.get('state', None)

    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,
        "overridePolicy": override_policy,
        "deployState": deploy_state,
    })
    return HttpResponse(html)
Example #3
0
def compare_deploys_2(request, name, stage):
    env = environs_helper.get_env_by_stage(request, name, stage)
    configs = {}
    for key, value in request.GET.iteritems():
        if key.startswith('chkbox_'):
            index = key[len('chkbox_'):]
            configs[index] = value
    indexes = configs.keys()
    start_build_id = configs[indexes[0]]
    end_build_id = configs[indexes[1]]
    if int(indexes[0]) > int(indexes[1]):
        start_build_id = configs[indexes[1]]
        end_build_id = configs[indexes[0]]

    start_build = builds_helper.get_build(request, start_build_id)
    startSha = start_build['commit']
    repo = start_build['repo']
    end_build = builds_helper.get_build(request, end_build_id)
    endSha = end_build['commit']
    scm_url = systems_helper.get_scm_url(request)
    diffUrl = "%s/%s/compare/%s...%s" % (scm_url, repo, endSha, startSha)
    return render(request, 'deploys/deploy_commits.html', {
        "env": env,
        "startSha": startSha,
        "endSha": endSha,
        "repo": repo,
        "title": "Commits between the two deploys",
        "diffUrl": diffUrl,
    })
Example #4
0
def compare_deploys_2(request, name, stage):
    env = environs_helper.get_env_by_stage(request, name, stage)
    configs = {}
    for key, value in request.GET.iteritems():
        if key.startswith('chkbox_'):
            index = key[len('chkbox_'):]
            configs[index] = value
    indexes = configs.keys()
    start_build_id = configs[indexes[0]]
    end_build_id = configs[indexes[1]]
    if int(indexes[0]) > int(indexes[1]):
        start_build_id = configs[indexes[1]]
        end_build_id = configs[indexes[0]]

    start_build = builds_helper.get_build(request, start_build_id)
    startSha = start_build['commit']
    repo = start_build['repo']
    end_build = builds_helper.get_build(request, end_build_id)
    endSha = end_build['commit']
    scm_url = systems_helper.get_scm_url(request)
    diffUrl = "%s/%s/compare/%s...%s" % (scm_url, repo, endSha, startSha)
    return render(
        request, 'deploys/deploy_commits.html', {
            "env": env,
            "startSha": startSha,
            "endSha": endSha,
            "repo": repo,
            "title": "Commits between the two deploys",
            "diffUrl": diffUrl,
        })
Example #5
0
def get_new_commits(request, name, stage):
    env = environs_helper.get_env_by_stage(request, name, stage)
    current_deploy = deploys_helper.get(request, env['deployId'])
    current_build = builds_helper.get_build(request, current_deploy['buildId'])
    startSha = current_build['commit']
    repo = current_build['repo']
    scm_url = systems_helper.get_scm_url(request)
    diffUrl = "%s/%s/compare/%s...%s" % (scm_url, repo, startSha, startSha)
    last_deploy = common.get_last_completed_deploy(request, env)
    if not last_deploy:
        return render(
            request, 'deploys/deploy_commits.html', {
                "env": env,
                "title": "No previous deploy found!",
                "startSha": startSha,
                "endSha": startSha,
                "repo": repo,
                "diffUrl": diffUrl,
            })

    last_build = builds_helper.get_build(request, last_deploy['buildId'])
    endSha = last_build['commit']
    diffUrl = "%s/%s/compare/%s...%s" % (scm_url, repo, endSha, startSha)
    return render(
        request, 'deploys/deploy_commits.html', {
            "env": env,
            "startSha": startSha,
            "endSha": endSha,
            "repo": repo,
            "title": "Commits since last deploy",
            "diffUrl": diffUrl,
        })
Example #6
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)
Example #7
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)
Example #8
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)
Example #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)
Example #10
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_and_tags(request,
                                               name=name,
                                               branch=branch,
                                               pageIndex=index,
                                               pageSize=size)
    scm_url = systems_helper.get_scm_url(request)
    deploy_state = None
    current_build_id = request.GET.get('current_build_id', None)
    override_policy = request.GET.get('override_policy')
    deploy_id = request.GET.get('deploy_id')
    current_build = None
    if current_build_id:
        current_build = builds_helper.get_build_and_tag(
            request, current_build_id)
        current_build = current_build.get('build')
    if deploy_id:
        deploy_config = deploys_helper.get(request, deploy_id)
        if deploy_config:
            deploy_state = deploy_config.get('state', None)

    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,
            "overridePolicy": override_policy,
            "deployState": deploy_state,
        })
    return HttpResponse(html)
Example #11
0
def deploy_build(request, name, stage, build_id):
    env = environs_helper.get_env_by_stage(request, name, stage)
    current_build = None
    if env.get('deployId'):
        current_deploy = deploys_helper.get(request, env['deployId'])
        current_build = builds_helper.get_build(request, current_deploy['buildId'])
    build = builds_helper.get_build_and_tag(request, build_id)
    builds = [build]
    scm_url = systems_helper.get_scm_url(request)
    deploy_state = deploys_helper.get(request, env['deployId'])['state']

    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),
        "deployState": deploy_state,
        "overridePolicy": env.get('overridePolicy'),
    })
    return HttpResponse(html)