Commit 3ec6d973 authored by 赵凯's avatar 赵凯 💬

pre -job 部署

parent e86f1215
......@@ -40,11 +40,17 @@ def checkProjIdGetResult(job):
raise Exception("无法识别的项目")
# 获取当前项目,当前环境最新commitid
def checkCommitid(projectid, env):
def checkCommitid(projectid, env, ref):
rst_data = getGits(projectid, env)
# 若是test, beta环境部署, 指定部署分支
# pre环境,则取指定的部署分支
if env in ['test', 'beta']:
ref = env
for data in rst_data:
# test;beta 环境最新节点拉取
if data['name'] == env:
if data['name'] == ref:
name = data['name']
committer_name = data['committer_name']
committed_date = data['committed_date']
......@@ -72,17 +78,32 @@ if len(argv) == 2:
else:
info = argv[2]
# 是否执行部署
isRun = False
if env in ['test', 'beta']:
isRun = True
# 是否job服务部署
job = ''
if len(argv) == 4:
isJob = argv[3]
if isJob == '-job':
job = '-job'
isRun = True
elif isJob == '-job2':
job = '-job2'
isRun = True
elif isJob == '-run':
job = ''
isRun = True
else:
sys.exit("job参数错误")
# 指定部署分支
ref = ''
if len(argv) == 5:
ref = argv[4]
# 识别项目
projectResult = checkProjIdGetResult(job)
......@@ -90,10 +111,12 @@ projectResult = checkProjIdGetResult(job)
projectid = projectResult['id']
# 拉取项目最新任务
rst_results_one = tasksEnv(projectid, env)
if ref == '':
ref = rst_results_one['ref']
# opms-pre命令,只会拉取最新环境节点,不会部署
# opms-pre-run命令,才会继续部署
if env in ['pre']:
print(f"请向 {rst_results_one['ref']} 合并你的开发分支,然后再执行 opms-pre-run 命令来部署预发环境")
if (not isRun) and (env in ['pre']):
print(f"请向 {rst_results_one['ref']} 合并你的开发分支,然后再执行 [opms pre \"部署pre\" -run] 命令来部署预发环境")
sys.exit()
# 项目环境部署信息
......@@ -102,7 +125,7 @@ projectEnvRef = next((env_ref for env_ref in projectResult['env_ref'] if env_ref
# print(projectEnvRef)
# 拉取提交节点
commitidData = checkCommitid(projectid, env)
commitidData = checkCommitid(projectid, env, ref)
commitid = commitidData['commitid']
# 创建部署任务
taskid = tasks(projectid, env, commitid, info)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment