Commit 54dc0aed by 李二毛

Merge branch 'development' into 'staging'

Development

See merge request liermao/microservice-autodevopspipelines!82
parents fc83af5b 61cde639
Pipeline #4279 failed in 0 seconds
......@@ -38,7 +38,7 @@ prod-major_job:
tags:
- production
staging-analysing-git-changes_job:
analysing-git-changes_job:
stage: analysing-git-changes
script:
- export Environment='Staging'
......@@ -48,7 +48,7 @@ staging-analysing-git-changes_job:
tags:
- staging
staging-synchronizing-config_job:
synchronizing-config_job:
stage: synchronizing-config
script:
- export Environment='Staging'
......@@ -58,7 +58,7 @@ staging-synchronizing-config_job:
tags:
- staging
staging-ci_job:
ci_job:
stage: ci
script:
- export Environment='Staging'
......@@ -68,21 +68,21 @@ staging-ci_job:
tags:
- staging
staging-cd_job:
cd_job:
stage: cd
variables:
CI_DEBUG_TRACE: "true"
script:
- echo ${CI_DEPLOY_USER}
- echo ${CI_COMMIT_REF_NAME}
- export Environment='Staging'
- # Import external functions
- chmod +x ./devops/PipeLines/Functions.common.sh
- source ./devops/PipeLines/Functions.common.sh
- FirstCharUpperCase $CI_COMMIT_REF_NAME environment
- export Environment=${environment}
- bash ./devops/PipeLines/Updating/004_CD.sh
only:
- staging
tags:
- staging
staging-is-k8s-ready_job:
is-k8s-ready_job:
stage: is-k8s-ready
script:
- export Environment='Staging'
......@@ -92,7 +92,7 @@ staging-is-k8s-ready_job:
tags:
- staging
staging-testing_job:
testing_job:
stage: testing
script:
- export Environment='Staging'
......@@ -102,7 +102,7 @@ staging-testing_job:
tags:
- staging
staging-clean-k8s_job:
clean-k8s_job:
stage: clean-k8s
script:
- export Environment='Staging'
......
......@@ -25,3 +25,10 @@ function DynamicVariableValueOf()
eval "output=\$$prefix$suffix"
eval $3=${output}
}
function FirstCharUpperCase()
{
declare input=$1
declare output=($(echo ${input} | sed -e "s/\b\(.\)/\u\1/g"))
eval $2=${output}
}
\ No newline at end of file
......@@ -35,18 +35,18 @@ function CD()
declare registryUserName=$2
declare serviceName=$3
declare version=$4
declare namespace=$5
declare ns=$5
Replace ${serviceName} '.' '-' appName
# repository name must be lowercase
ToLower "${registryHost}/${registryUserName}/${serviceName}:${version}" imagefullname
ToLower ${appName} appNameOfK8s
kubectl -n ${namespace} set image deployments/${appNameOfK8s} "${appNameOfK8s}=${imagefullname}";
kubectl -n ${ns} set image deployments/${appNameOfK8s} "${appNameOfK8s}=${imagefullname}";
# [compatible]Staging environment does not need to change version number.
if [ "${Environment}" == "Staging" ]; then
kubectl -n ${namespace} scale deploy ${appNameOfK8s} --replicas=0;
kubectl -n ${namespace} scale deploy ${appNameOfK8s} --replicas=1;
kubectl -n ${ns} scale deploy ${appNameOfK8s} --replicas=0;
kubectl -n ${ns} scale deploy ${appNameOfK8s} --replicas=1;
fi
echo "Deployment[${Environment}] for ${appName}:${version} has been successful."
}
\ No newline at end of file
#!/bin/bash
# Import external functions
chmod +x ./devops/PipeLines/Functions.deploy.sh
source ./devops/PipeLines/Functions.deploy.sh
GetNameSpace namespace
echo ${namespace}
function CD()
{
declare namespace=$1
echo ${namespace}
}
CD ${namespace}
\ No newline at end of file
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