Example #1
0
def createSingleAppTag(tag_name=None, ref=None, project_id=None, app_id=None):
    l = Api()
    # below project is gitlab project concept
    gitlab_project = get_evo_or_evoProjects_gitlab_project(project_id, app_id)
    rsn = l.create_project_tag(
        project_id=gitlab_project['id'], tag_name=tag_name, ref=ref)
    return rsn
Example #2
0
def createSingleAppBranch(origin=None, target=None, project_id=None, app_id=None):
    l = Api()
    gitlab_project = get_evo_or_evoProjects_gitlab_project(project_id, app_id)
    # below project is gitlab project concept
    if not l.search_project_branch(project_id=gitlab_project['id'], branch=target):
        l.create_project_branch(
            project_id=gitlab_project['id'], origin_branch_name=origin, target_branch_name=target)
    return True
Example #3
0
def deleteSingleAppBranch(project_id=None, branch_name="", app_name=""):
    l = Api()
    app = App.objects.get(project__id=project_id, name=app_name)
    # below project is gitlab project concept
    gitlab_project = get_evo_or_evoProjects_gitlab_project(project_id, app.id)
    if l.search_project_branch(project_id=gitlab_project['id'], branch=branch_name):
        l.delete_project_branch(
            project_id=gitlab_project['id'], branch_name=branch_name)
    return True
Example #4
0
def createTagBy(project_id=None, tag_name="", ref=""):
    project = Project.objects.get(id=project_id)
    apps = project.app_set.all()
    l = Api()
    for app in apps:
        gitlab_project = get_evo_or_evoProjects_gitlab_project(
            project_id, app.id)
        l.create_project_tag(
            project_id=gitlab_project['id'], tag_name=tag_name, ref=ref)
    return True, ""
Example #5
0
def get_evo_or_evoProjects_gitlab_project(project_id, app_id):
    app = App.objects.get(id=app_id)
    project = Project.objects.get(id=project_id)
    group_name, app_name = app.slugName.split("/")[-2:]
    l = Api()
    if project.name == "evo":
        gitlab_project = l.get_group_project_by_name(group_name=group_name, project_name=app_name,
                                                     full_path="software/evo/" + group_name)
    else:
        gitlab_project = l.get_group_project_by_name(group_name=group_name, project_name=app_name,
                                                     full_path="software/evo-projects/" + group_name)
    return gitlab_project
Example #6
0
def deleteBranchby(project_id=None, branch_name=""):
    project = Project.objects.get(id=project_id)
    l = Api()
    # below project is gitlab project concept
    apps = project.app_set.all()
    for app in apps:
        gitlab_project = get_evo_or_evoProjects_gitlab_project(
            project_id, app.id)
        if l.search_project_branch(project_id=gitlab_project['id'], branch=branch_name):
            l.delete_project_branch(
                project_id=gitlab_project['id'], branch_name=branch_name)
    return True
Example #7
0
def createBranchBy(origin=None, target=None, project_id=None):
    project = Project.objects.get(id=project_id)
    l = Api()
    # below project is gitlab project concept
    apps = project.app_set.all()
    for app in apps:
        gitlab_project = get_evo_or_evoProjects_gitlab_project(
            project_id, app.id)
        if not l.search_project_branch(project_id=gitlab_project['id'], branch=target):
            l.create_project_branch(
                project_id=gitlab_project['id'], origin_branch_name=origin, target_branch_name=target)
    return True
Example #8
0
def build_docker_compose(images, lujin):
    # dc_path = settings.DC_PATH
    # f = open(dc_path, 'r')
    # file_data = f.read()
    # f.close()
    # 更改通过api获取gitlab项目的文件
    api = Api()
    file_data = api.get_project_compose_content(lujin)
    for image in images:
        name, version = image.split(":")
        name = "{%s}" % name
        file_data = file_data.replace(name, image)
    return file_data
Example #9
0
import os, sys
from Api.gitlabApi import Api
from Api.ldapApi import Uldap
import gitlab
sys.path.append("/opt/flashhold-devops/flashholdDevops")

if __name__ == "__main__":
    import django
    django.setup()
    from app.models import *
    git = Api()
    users = git.get_users()
    ldap = Uldap()
    for user in users:
        if not User.objects.filter(username=user["username"]):
            uobj = User.objects.create(username=user["username"],
                                       email="*****@*****.**" %
                                       user["username"])
            uobj.set_password("123456")
            rsn, msg = ldap.search_user(uobj.username)
            if not rsn:
                ldap.create_ldapuser(uobj.username, "123456")
        else:
            uobj = User.objects.filter(username=user["username"])[0]
            uobj.last_name = user["username"]
            uobj.save()

    for item in [
            "a51050", 'a51043', 'a51028', 'a51051', 'a31024-002', 'a31030-002',
            'a51040'
    ]: