def init_dir(self): self.BASE_DIR = "/tmp/target_app/" exit_code = utils.exec_command(["mkdir", "-p", self.BASE_DIR]) if (exit_code != 0): print('exit_code: {}'.format(exit_code)) os.chdir(self.BASE_DIR)
def do_job(self, repo): try: job_url = repo['jenkins_host'] return utils.exec_command([ "curl", "-X", "POST", job_url, "--user", "[email protected]:11d76e49d3768fbceda674b237d8538290" ]) except Exception as exp: api.abort(404, "jenkins error : {}".format(exp))
def clone(self, payload): # TODO: git clone 성공하면 성공 실패하면 오류 try: self.clear() self.init_dir() print("get payload:{}".format(payload)) exit_code = utils.exec_command(["git", "clone", payload['repo']]) if(exit_code is not 0): Exception('exit_code') self.chworkdir(payload['repo']) # git proto_test_branch 삭제 utils.exec_command(["git", "push", "origin", "--delete", self.proto_test_branch]) #git branch(jenkins)를 생성한다 utils.exec_command(["git", "checkout", "-b", self.proto_test_branch]) return exit_code except Exception as exp: print("git clone failed cause : {}".format(exp)) api.abort(404, "git clone failed cause : {}".format(exp))
def fetch(self, payload): try: self.init_dir() repo_dir = payload['repo'] repo_name = repo_dir.split('/')[len(repo_dir.split('/')) - 1].split('.')[0] os.chdir("{}/{}".format(self.BASE_DIR, repo_name)) name = payload.get('name', 'java-mvn-springboot') group = payload.get('group', 'sample') service = payload.get('service', 'service') exit_code = utils.exec_command([ "valve", "fetch", "--name", name, "--overwrite", "--group", group, "--service", service ]) self.path_deploy() return exit_code except Exception as exp: api.abort(404, "valve fetch failed cause : {}".format(exp))
def push(self, payload): #git push self.init_dir() self.chworkdir(payload['repo']) utils.exec_command(["git", "push", "--set-upstream", "origin", self.proto_test_branch])
def add(self, payload): self.init_dir() self.chworkdir(payload['repo']) utils.exec_command(["git", "add", "."]) utils.exec_command(["git", "commit", "-m", "auto generator by ifs proto type"])
def clear(self): exit_code = utils.exec_command(["rm", "-rf", self.BASE_DIR]) return exit_code