예제 #1
0
파일: api.py 프로젝트: zq920320/pydelo
def update_deploy_by_id(id):
    action = request.form.get("action")
    deploy = deploys.get(id)
    if action == "redeploy":
        new_deploy = deploys.create(user_id=deploy.user_id,
                                    project_id=deploy.project_id,
                                    host_id=deploy.host_id,
                                    mode=deploy.mode,
                                    status=2,
                                    branch=deploy.branch,
                                    version=deploy.version,
                                    softln_filename=deploy.softln_filename)
        deploys.deploy(new_deploy)
        return jsonify(dict(rc=0, data=dict(id=new_deploy.id)))
    elif action == "rollback":
        new_deploy = deploys.create(user_id=deploy.user_id,
                                    project_id=deploy.project_id,
                                    host_id=deploy.host_id,
                                    mode=2,
                                    status=2,
                                    branch=deploy.branch,
                                    version=deploy.version,
                                    softln_filename=deploy.softln_filename)
        deploys.rollback(new_deploy)
        return jsonify(dict(rc=0, data=dict(id=new_deploy.id)))
    else:
        raise Error(10000, msg=None)
예제 #2
0
파일: api.py 프로젝트: bingone/pydelo
def update_deploy_by_id(id):
    action = request.form.get("action")
    deploy = deploys.get(id)
    if action == "redeploy":
        new_deploy = deploys.create(
            user_id=deploy.user_id,
            project_id=deploy.project_id,
            host_id=deploy.host_id,
            mode=deploy.mode,
            status=2,
            branch=deploy.branch,
            version=deploy.version,
            softln_filename=deploy.softln_filename)
        deploys.deploy(new_deploy)
        return jsonify(dict(rc=0, data=dict(id=new_deploy.id)))
    elif action == "rollback":
        new_deploy = deploys.create(
            user_id=deploy.user_id,
            project_id=deploy.project_id,
            host_id=deploy.host_id,
            mode=2,
            status=2,
            branch=deploy.branch,
            version=deploy.version,
            softln_filename=deploy.softln_filename)
        deploys.rollback(new_deploy)
        return jsonify(dict(rc=0, data=dict(id=new_deploy.id)))
    else:
        raise Error(10000, msg=None)
예제 #3
0
파일: api.py 프로젝트: zq920320/pydelo
def api_post_deploy():
    project_id = request.args.get("project_id")
    host_id = request.args.get("host_id")
    branch = request.form.get("branch")
    commit = request.form.get("commit")
    deploy = deploys.create(
        user_id=g.user.id,
        project_id=project_id,
        host_id=host_id,
        mode=0,
        status=2,
        branch=branch,
        version=commit,
        softln_filename=time.strftime("%Y%m%d-%H%M%S") + "-" + commit,
    )
    deploys.deploy(deploy)
    return jsonify(dict(rc=0, data=dict(id=deploy.id)))
예제 #4
0
파일: api.py 프로젝트: bingone/pydelo
def api_post_deploy():
    project_id = request.args.get("project_id")
    host_id = request.args.get("host_id")
    mode = request.form.get("mode", type=int)
    branch = request.form.get("branch") if mode == 0 else ""
    tag = request.form.get("tag")
    commit = request.form.get("commit") if mode == 0 else tag
    deploy = deploys.create(
        user_id=g.user.id,
        project_id=project_id,
        host_id=host_id,
        mode=mode,
        status=2,
        branch=branch,
        version=commit,
        softln_filename=time.strftime("%Y%m%d-%H%M%S") + "-" + commit,
        )
    deploys.deploy(deploy)
    return jsonify(dict(rc=0, data=dict(id=deploy.id)))
예제 #5
0
파일: api.py 프로젝트: nevernet/pydelo
def update_deploy_by_id(id):
    action = request.form.get("action")
    deploy = deploys.get(id)
    if action == "redeploy":
        new_deploy = deploys.create(
            user_id=deploy.user_id,
            project_id=deploy.project_id,
            host_id=deploy.host_id,
            mode=deploy.mode,
            status=2,
            branch=deploy.branch,
            version=deploy.version,
            softln_filename=deploy.softln_filename)
        deploys.deploy(new_deploy)
        return jsonify(dict(rc=0, data=dict(id=new_deploy.id)))
    elif action == "rollback":
        # new_deploy = deploys.create(
        #     user_id=deploy.user_id,
        #     project_id=deploy.project_id,
        #     host_id=deploy.host_id,
        #     mode=2,
        #     status=2,
        #     branch=deploy.branch,
        #     version=deploy.version,
        #     softln_filename=deploy.softln_filename)
        # deploys.rollback(new_deploy)

        # return jsonify(dict(rc=0, data=dict(id=new_deploy.id)))

        msg = deploys_new.rollback(deploy)
        deploys.update(deploy, **dict(deploy_status=2))
        return jsonify(dict(rc=0, msg=msg))

    elif action == "publish":
        msg = deploys_new.publish(deploy)
        deploys.update(deploy, **dict(deploy_status=1))
        return jsonify(dict(rc=0, msg=msg))
    elif action == "cancel":
        deploys.update(deploy, **dict(deploy_status=99))
        return jsonify(dict(rc=0, data=None))
    else:
        return jsonify(dict(rc=-1, msg="action is not supported"))
예제 #6
0
def webhooks_push_events():
    project_id = request.args.get("project_id")
    host_id = request.args.get("host_id")
    data = request.json
    branch = data["ref"].split("/", 2)[-1]
    version = data["after"][:7]
    # 只针对dev分支进行deploy
    if data["ref"] == "refs/heads/dev" and data["total_commits_count"] > 0:
        deploy = deploys.create(
            user_id=g.user.id,
            project_id=project_id,
            host_id=host_id,
            mode=0,
            status=2,
            branch=branch,
            version=version,
            softln_filename=time.strftime("%Y%m%d-%H%M%S") + "-" + version,
            )
        deploys.deploy(deploy)
        return jsonify({"rc": 0}), 200
    else:
        return jsonify({"rc": 0}), 204
예제 #7
0
def webhooks_tag_push_events():
    project_id = request.args.get("project_id")
    host_id = request.args.get("host_id")
    data = request.json
    tag = data["ref"].split("/", 2)[-1]
    logger.debug(repr(data))
    # 只针对tag push
    if data["object_kind"] == "tag_push" and data["total_commits_count"] > 0:
        deploy = deploys.create(
            user_id=g.user.id,
            project_id=project_id,
            host_id=host_id,
            mode=1,
            status=3,
            branch="",
            version=tag,
            softln_filename=time.strftime("%Y%m%d-%H%M%S") + "-" + tag,
            )
        deploys.deploy(deploy)
        return jsonify({"rc": 0}), 200
    else:
        return jsonify({"rc": 0}), 204
예제 #8
0
파일: webhooks.py 프로젝트: bradbann/pydelo
def webhooks_tag_push_events():
    project_id = request.args.get("project_id")
    host_id = request.args.get("host_id")
    data = request.json
    tag = data["ref"].split("/", 2)[-1]
    logger.debug(repr(data))
    # 只针对tag push
    if data["object_kind"] == "tag_push" and data["total_commits_count"] > 0:
        deploy = deploys.create(
            user_id=g.user.id,
            project_id=project_id,
            host_id=host_id,
            mode=1,
            status=2,
            branch="",
            version=tag,
            softln_filename=time.strftime("%Y%m%d-%H%M%S") + "-" + tag,
            )
        deploys.deploy(deploy)
        return jsonify({"rc": 0}), 200
    else:
        return jsonify({"rc": 0}), 204
예제 #9
0
def webhooks_push_events():
    project_id = request.args.get("project_id")
    host_id = request.args.get("host_id")
    data = request.json
    branch = data["ref"].split("/", 2)[-1]
    version = data["after"][:7]
    logger.debug(repr(data))
    # 只针对dev分支进行deploy
    if data["ref"] == "refs/heads/dev" and data["total_commits_count"] > 0:
        deploy = deploys.create(
            user_id=g.user.id,
            project_id=project_id,
            host_id=host_id,
            mode=0,
            status=3,
            branch=branch,
            version=version,
            softln_filename=time.strftime("%Y%m%d-%H%M%S") + "-" + version,
            )
        deploys.deploy(deploy)
        return jsonify({"rc": 0}), 200
    else:
        return jsonify({"rc": 0}), 204