def project_branch_commits(id, branch): print(id) project = projectService.get(id) print(project) # projectService.git_clone(project) return jsonify(dict(code=200, data=projectService.git_branch_commit_log(project, branch)))
def delProject(id): opertorId = session.get("user")[u'id'] dictM = projectService.get(id) userService.delete(dictM) logger.info("userId is %s del project,projectInfo is %s", opertorId, str(dictM)) return jsonify(dict(code=200))
def editProject(): dictId = request.form.get("id") origin = projectService.get(dictId) originS = str(origin) projectService.update(origin, **request.form.to_dict()) opertorId = session.get("user")[u'id'] logger.info( "userId is %s edit project,origin projectInfo is %s,dest projectInfo is", opertorId, originS, str(origin)) return jsonify(dict(code=200))
def project_info(id): projecthosts = projectHostService.find(project_id=id).all() hostids = [] for projecthost in projecthosts: hostids.append(projecthost.host_id) project = projectService.get(id) hosts=hostService.getByIds(hostids) deploy = deployService.first(project_id=id) return render_template('projectInfo.html',hosts=hosts,project=project, user=session['user'],projectdicts=projectService.dict_projects(), deploy=deploy)
def deploy(self, form): project = projectService.get(form.project_id) git = Git(project.name, project.repo_url) # clone git.clone() # checkout git.checkout_branch(form.branch, form.commit) # deploy git.package(form.branch) prohosts = projectHostService.find(project_id=form.project_id).all() t = threading.Thread(target=deploy_thread, args=( prohosts, git, project, ), name="deploy-thread") t.start() t.join()
def rollback(self, form): dest = "/home/aaa/" project = projectService.get(form.project_id) git = Git(project.name, project.repo_url) # checkout git.rollback() # deploy git.package(form.branch) prohosts = projectHostService.find(project_id=form.project_id).all() for prohost in prohosts: host = hostService.get(prohost.host_id) cmd = ( "rsync -avzq --include='target/' --include='target/*.jar' --exclude='*' --exclude='*/' " "--rsh=\"sshpass -p {ssh_pass} ssh -p {ssh_port}\" " " {local_dest}/ {ssh_user}@{ssh_host}:" "{remote_dest}/") cmd = cmd.format(ssh_pass=host.ssh_password, ssh_port=host.ssh_port, local_dest=git.location + project.name, ssh_user=host.ssh_username, ssh_host=host.host_ip, remote_dest=dest + project.name) git.deploy(cmd)
def api_project_branches(id): print(id) project = projectService.get(id) print(project) projectService.git_clone(project) return jsonify(dict(code=200, data=projectService.git_branch(project)))