Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
opms-command
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
赵凯
opms-command
Commits
3ec6d973
Commit
3ec6d973
authored
Mar 26, 2024
by
赵凯
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pre -job 部署
parent
e86f1215
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
5 deletions
+28
-5
opms.py
opms.py
+28
-5
No files found.
opms.py
View file @
3ec6d973
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment