From d4a5b6e942d4c7c73fe3749281eca04fd6539a2f Mon Sep 17 00:00:00 2001 From: chenzhihang <709011834@qq.com> Date: Thu, 24 Oct 2024 14:09:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E7=BD=B2=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E9=83=A8=E7=BD=B2=E5=8D=8E=E4=B8=BA=E4=BA=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- k8s/build.sh | 19 ------------------- k8s/build_and_deploy.sh | 17 ++++++++++++++++- k8s/deploy.sh | 12 ++++++------ 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/k8s/build.sh b/k8s/build.sh index 175ccb60..9c5a8524 100755 --- a/k8s/build.sh +++ b/k8s/build.sh @@ -41,25 +41,6 @@ fi baseDir="/data/code/manage-platform" cd ${baseDir} -# 拉取指定分支的最新代码 -echo "Checking out and pulling branch $branch..." - -git stash -git checkout $branch -if [ $? -ne 0 ]; then - echo "切换到分支 $branch 失败,请检查分支名称是否正确!" - exit 1 -fi - -git stash -git pull origin $branch -if [ $? -ne 0 ]; then - echo "拉取代码失败,请检查网络或联系管理员!" - exit 1 -fi - -chmod +777 ${baseDir}/k8s/*.sh - # 创建目录 mkdir -p ${baseDir}/k8s/dockerfiles/jar mkdir -p ${baseDir}/k8s/dockerfiles/html diff --git a/k8s/build_and_deploy.sh b/k8s/build_and_deploy.sh index 08e3d338..8959d08b 100755 --- a/k8s/build_and_deploy.sh +++ b/k8s/build_and_deploy.sh @@ -3,7 +3,6 @@ #记录开始时间 startTime=$(date +%s) - #build # 默认参数 branch="master" @@ -46,8 +45,24 @@ if [[ ! " ${valid_envs[@]} " =~ " $env " ]]; then exit 1 fi +# 拉取指定分支的最新代码 +echo "Checking out and pulling branch $branch..." + git stash git checkout $branch +if [ $? -ne 0 ]; then + echo "切换到分支 $branch 失败,请检查分支名称是否正确!" + exit 1 +fi + +git stash +git pull origin $branch +if [ $? -ne 0 ]; then + echo "拉取代码失败,请检查网络或联系管理员!" + exit 1 +fi + +chmod +777 ${baseDir}/k8s/*.sh # 登录到目标环境 baseDir="/data/code/manage-platform" diff --git a/k8s/deploy.sh b/k8s/deploy.sh index 407d546d..fd8d70a5 100755 --- a/k8s/deploy.sh +++ b/k8s/deploy.sh @@ -52,7 +52,7 @@ else fi baseDir=/data/code/manage-platform -tag=$(date +'%Y%m%d%H%M') +tag=$(date +'%Y%m%d')-arm remote_deploy_dir=/home/deploy/manage-platform # 构建镜像函数 @@ -143,15 +143,15 @@ fi if [ "$service" == "all" ]; then #部署前端 - build_and_deploy "nginx-dockerfile" "172.20.32.187/ci4s/ci4s-front:${tag}" "k8s-12front.yaml" + build_and_deploy "nginx-dockerfile" "ccr.ccs.tencentyun.com/somunslotus/ci4s-front:${tag}" "k8s-12front.yaml" #部署管理平台 - build_and_deploy "managent-dockerfile" "172.20.32.187/ci4s/ci4s-managent:${tag}" "k8s-7management.yaml" + build_and_deploy "managent-dockerfile" "ccr.ccs.tencentyun.com/somunslotus/ci4s-managent:${tag}" "k8s-7management.yaml" #部署认证中心 - build_and_deploy "auth-dockerfile" "172.20.32.187/ci4s/ci4s-auth:${tag}" "k8s-5auth.yaml" + build_and_deploy "auth-dockerfile" "ccr.ccs.tencentyun.com/somunslotus/ci4s-auth:${tag}" "k8s-5auth.yaml" #部署网关 - build_and_deploy "gateway-dockerfile" "172.20.32.187/ci4s/ci4s-gateway:${tag}" "k8s-4gateway.yaml" + build_and_deploy "gateway-dockerfile" "ccr.ccs.tencentyun.com/somunslotus/ci4s-gateway:${tag}" "k8s-4gateway.yaml" #部署系统服务 - build_and_deploy "system-dockerfile" "172.20.32.187/ci4s/ci4s-system:${tag}" "k8s-6system.yaml" + build_and_deploy "system-dockerfile" "ccr.ccs.tencentyun.com/somunslotus/ci4s-system:${tag}" "k8s-6system.yaml" #部署配置中心 deploy_nacos "k8s-3nacos.yaml" fi