Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
deploy_script
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Script
deploy_script
Commits
4a4bbe39
Commit
4a4bbe39
authored
Feb 03, 2021
by
jinkaiqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
9adef247
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
docker_ci_tools.sh
docker_ci_tools.sh
+14
-5
No files found.
docker_ci_tools.sh
View file @
4a4bbe39
#!/bin/bash
#!/bin/bash
cmd
=
$1
cmd
=
$1
docker_file_name
=
$2
# 清除release镜像版本
# 清除release镜像版本
function
clear_release_image
()
{
function
clear_release_image
()
{
...
@@ -18,6 +19,10 @@ function foramt_image_version() {
...
@@ -18,6 +19,10 @@ function foramt_image_version() {
else
else
image_version
=
"v"
`
echo
$CI_COMMIT_REF_NAME
|
grep
-Eo
'[0-9]+.[0-9]+'
`
image_version
=
"v"
`
echo
$CI_COMMIT_REF_NAME
|
grep
-Eo
'[0-9]+.[0-9]+'
`
fi
fi
if
[[
$image_version
==
"v"
]]
||
[[
$image_version
==
"v_beta"
]]
;
then
echo
"修正后的镜像版本有误:"
$image_version
",原版本为:"
$CI_COMMIT_REF_NAME
exit
1
fi
echo
"版本:"
$CI_COMMIT_REF_NAME
"成功修正为:"
$image_version
echo
"版本:"
$CI_COMMIT_REF_NAME
"成功修正为:"
$image_version
}
}
# 写入版本号
# 写入版本号
...
@@ -30,7 +35,11 @@ function log_version() {
...
@@ -30,7 +35,11 @@ function log_version() {
function
build_docker_image
()
{
function
build_docker_image
()
{
log_version
log_version
foramt_image_version
foramt_image_version
docker build
-t
${
APP_IMAGE
}
:
$image_version
.
if
[
-z
"
$docker_file_name
"
]
;
then
docker build
-t
${
APP_IMAGE
}
:
$image_version
.
||
exit
1
else
docker build
-f
$docker_file_name
-t
${
APP_IMAGE
}
:
$image_version
.
||
exit
1
fi
# 正式版本构建后,清除release版本
# 正式版本构建后,清除release版本
tags_reg
=
'^[0-9]+.[0-9]+.[0-9]+$'
tags_reg
=
'^[0-9]+.[0-9]+.[0-9]+$'
if
[[
"
$CI_COMMIT_REF_NAME
"
=
~
$tags_reg
]]
;
then
if
[[
"
$CI_COMMIT_REF_NAME
"
=
~
$tags_reg
]]
;
then
...
@@ -41,7 +50,7 @@ function build_docker_image() {
...
@@ -41,7 +50,7 @@ function build_docker_image() {
# 主流程
# 主流程
if
[
-z
"
$cmd
"
]
;
then
if
[
-z
"
$cmd
"
]
;
then
echo
"命令不能为空"
echo
"命令不能为空"
exit
0
exit
1
elif
[
"
$cmd
"
==
"build"
]
;
then
elif
[
"
$cmd
"
==
"build"
]
;
then
echo
"build..."
echo
"build..."
build_docker_image
build_docker_image
...
@@ -52,9 +61,9 @@ elif [ "$cmd" == "push" ]; then
...
@@ -52,9 +61,9 @@ elif [ "$cmd" == "push" ]; then
elif
[
"
$cmd
"
==
"push_ali"
]
;
then
elif
[
"
$cmd
"
==
"push_ali"
]
;
then
echo
"push_ali..."
echo
"push_ali..."
foramt_image_version
foramt_image_version
docker tag
${
APP_IMAGE
}
:
$image_version
${
ALI_IMAGE
}
:
$image_version
docker tag
${
APP_IMAGE
}
:
$image_version
${
ALI_IMAGE
}
:
$image_version
||
exit
1
docker push
${
ALI_IMAGE
}
:
$image_version
docker push
${
ALI_IMAGE
}
:
$image_version
||
exit
1
else
else
echo
"无效命令:
$cmd
"
echo
"无效命令:
$cmd
"
exit
0
exit
1
fi
fi
\ No newline at end of file
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