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
c047431e
Commit
c047431e
authored
Mar 27, 2024
by
赵凯
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix pre
parent
b4997121
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
8 deletions
+18
-8
tasks_api.py
apis/tasks_api.py
+5
-2
opms.py
opms.py
+13
-6
No files found.
apis/tasks_api.py
View file @
c047431e
#!/usr/bin/env python3
import
sys
import
requests
,
json
from
common.token
import
getToken
def
tasks
(
projectid
,
env
,
commitid
,
info
):
def
tasks
(
projectid
,
env
,
commitid
,
info
,
ref
):
cookie
=
getToken
()
url
=
"https://gw.qimai.shop/api/jenkins/jenkinsjob/tasks/"
# payload="{\"gray\":false,\"eta\":\"\",\"pname\":47,\"env\":\"test\",\"ref\":\"test\",\"info\":\"test 部署, 桌码迁移\",\"commitid\":\"e974fb255fd38020367d0a6ed54949d121ecf548\"}"
payload
=
f
'{{"gray":false,"eta":"","pname":"{projectid}","env":"{env}","ref":"{env}","info":"{info}","commitid":"{commitid}"}}'
payload
=
f
'{{"gray":false,"eta":"","pname":"{projectid}","env":"{env}","ref":"{ref}","info":"{info}","commitid":"{commitid}"}}'
payload
=
payload
.
encode
(
"utf-8"
)
.
decode
(
"latin1"
)
headers
=
{
'authority'
:
'gw.qimai.shop'
,
...
...
opms.py
View file @
c047431e
...
...
@@ -70,7 +70,7 @@ if len(argv) == 1:
else
:
env
=
argv
[
1
]
if
env
not
in
[
"test"
,
"beta"
,
"pre"
,
"pre-run"
]:
if
env
not
in
[
"test"
,
"beta"
,
"pre"
]:
sys
.
exit
(
"env环境参数设置错误"
)
if
len
(
argv
)
==
2
:
...
...
@@ -85,7 +85,7 @@ if env in ['test', 'beta']:
# 是否job服务部署
job
=
''
if
len
(
argv
)
=
=
4
:
if
len
(
argv
)
>
=
4
:
isJob
=
argv
[
3
]
if
isJob
==
'-job'
:
job
=
'-job'
...
...
@@ -101,7 +101,7 @@ if len(argv) == 4:
# 指定部署分支
ref
=
''
if
len
(
argv
)
=
=
5
:
if
len
(
argv
)
>
=
5
:
ref
=
argv
[
4
]
...
...
@@ -111,8 +111,15 @@ projectResult = checkProjIdGetResult(job)
projectid
=
projectResult
[
'id'
]
# 拉取项目最新任务
rst_results_one
=
tasksEnv
(
projectid
,
env
)
if
ref
==
''
:
ref
=
rst_results_one
[
'ref'
]
# 若是test, beta环境部署, 指定部署分支
# pre环境,则取指定的部署分支
if
env
in
[
'test'
,
'beta'
]:
ref
=
env
else
:
if
ref
==
''
:
ref
=
rst_results_one
[
'ref'
]
# opms-pre命令,只会拉取最新环境节点,不会部署
# opms-pre-run命令,才会继续部署
if
(
not
isRun
)
and
(
env
in
[
'pre'
]):
...
...
@@ -128,7 +135,7 @@ projectEnvRef = next((env_ref for env_ref in projectResult['env_ref'] if env_ref
commitidData
=
checkCommitid
(
projectid
,
env
,
ref
)
commitid
=
commitidData
[
'commitid'
]
# 创建部署任务
taskid
=
tasks
(
projectid
,
env
,
commitid
,
info
)
taskid
=
tasks
(
projectid
,
env
,
commitid
,
info
,
ref
)
time
.
sleep
(
3
)
# 执行部署任务 or 执行集群部署任务
multi_zone_deploy
=
projectEnvRef
.
get
(
'multi_zone_deploy'
,
False
)
...
...
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