Exemple #1
0
def update_job_step(uuid, step, status):
    job = get_job_by_uuid(uuid)
    info = job['info'] or []
    step['status'] = status
    info.append(step)
    # steps & env already stringified
    get_cursor().execute(" UPDATE jobs set steps = ? where uuid=? ",
                         (json.dumps(info), str(uuid)))
    commit_db()
Exemple #2
0
def add_project(project):
    # https://docs.gitlab.com/ee/api/projects.html#get-single-project
    print("add_project")
    print(project)
    uuid = uuid4()
    name = project['path_with_namespace']
    id = project['id']
    get_cursor().execute(INSERT_PROJECT_SQL, (str(uuid), int(id), name, dumps(project)))
    commit_db()
Exemple #3
0
def update_project_pipeline(id, branch, steps, env):
    # steps & env already stringified
    get_cursor().execute(" UPDATE projects set build_branch= ?, pipeline_steps= ?, pipeline_envs= ? where id=? ",
                         (branch, steps, env, id))
    commit_db()
Exemple #4
0
def get_project_by_uuid(uuid):
    return get_cursor().execute("Select * from projects where uuid=? ;", uuid)
Exemple #5
0
def get_project_by_id(id):
    return get_cursor().execute("Select * from projects where id= ? ;", (str(id),)).fetchone()
Exemple #6
0
def get_projects(**kwargs):
    page = kwargs['page'] if 'page' in kwargs else 10
    page_size = kwargs['page_size'] if 'page_size' in kwargs else 0
    print(page)
    print(page_size)
    return get_cursor().execute(SELECT_PROJECTS_SQL, (page, page_size * page)).fetchall()
Exemple #7
0
def init_db():
    get_cursor().execute(CREATE_TABLE_JOBS_SQL)
    get_cursor().execute(CREATE_TABLE_PROJECTS_SQL)
Exemple #8
0
def update_job_status(uuid, status):
    # steps & env already stringified
    get_cursor().execute(" UPDATE jobs set status= ?  where uuid=? ",
                         (status, uuid))
    commit_db()
Exemple #9
0
def get_job_by_uuid(uuid):
    return get_cursor().execute("Select * from jobs where uuid= ? ;",
                                (str(uuid), )).fetchone()
Exemple #10
0
def create_job(project_id):
    # https://docs.gitlab.com/ee/api/projects.html#get-single-project
    uuid = uuid4()
    get_cursor().execute(INSERT_JOB_SQL, (str(uuid), int(project_id)))
    commit_db()