Commit f9d5e47c by 李二毛

Merge branch 'development' into 'rel/major'

提取单独的环境变量

See merge request liermao/microservice-autodevopspipelines!55
parents b8617346 8409c887
Pipeline #4187 failed with stages
in 57 seconds
stages: stages:
- build - build
- staging-release-major - staging-release-major
- prod-release-major
build_job: build_job:
stage: build stage: build
...@@ -12,9 +13,7 @@ build_job: ...@@ -12,9 +13,7 @@ build_job:
staging-major_job: staging-major_job:
stage: staging-release-major stage: staging-release-major
script: script:
- export RegistryHost='registry.geekbuying.com:8100'
- export Environment='Staging' - export Environment='Staging'
- export K8sApiServer='https://172.24.83.222:6443'
# 001 Continuous integration image to registry. # 001 Continuous integration image to registry.
- bash ./devops/PipeLines/Creation/001_CI.sh - bash ./devops/PipeLines/Creation/001_CI.sh
...@@ -26,8 +25,31 @@ staging-major_job: ...@@ -26,8 +25,31 @@ staging-major_job:
- bash ./devops/PipeLines/Creation/003_ReleaseMajor.sh - bash ./devops/PipeLines/Creation/003_ReleaseMajor.sh
# 004 Create gateway route. # 004 Create gateway route.
- export KongApiServer='http://127.0.0.1:81' - bash ./devops/PipeLines/Creation/Gateways/Kong/004_CreateGatewayRoute.sh
- export KongRouteDomain='staging-api.geekbuy.cn' only:
- rel/major
tags:
- staging
prod-major_job:
stage: prod-release-major
script:
- export RegistryHost='dockerhub.geekbuying.com:8100'
- export Environment='Production'
- export K8sApiServer='https://10.76.134.3:6443'
# 001 Continuous integration image to registry.
- bash ./devops/PipeLines/Creation/001_CI.sh
# 002 Create config information to k8s's configmap.
- bash ./devops/PipeLines/Creation/002_CreateConfig.sh
# 003 Release major to k8s's cluster.
- bash ./devops/PipeLines/Creation/003_ReleaseMajor.sh
# 004 Create gateway route.
- export KongApiServer='http://10.76.134.4:81'
- export KongRouteDomain='s.geekbuying.com'
- bash ./devops/PipeLines/Creation/Gateways/Kong/004_CreateGatewayRoute.sh - bash ./devops/PipeLines/Creation/Gateways/Kong/004_CreateGatewayRoute.sh
only: only:
- rel/major - rel/major
......
...@@ -18,7 +18,7 @@ dotnet build ${solutionName} ...@@ -18,7 +18,7 @@ dotnet build ${solutionName}
echo "" echo ""
echo "Please check the version of each microservice carefully !!!" echo "Please check the version of each microservice carefully !!!"
#GetServices services GetRegistryHost RegistryHost
for servicePrefix in `ls ./src/Services|xargs -d '/'` for servicePrefix in `ls ./src/Services|xargs -d '/'`
do do
GetServiceName ${servicePrefix} serviceName GetServiceName ${servicePrefix} serviceName
......
...@@ -14,7 +14,12 @@ GetNameSpace namespace ...@@ -14,7 +14,12 @@ GetNameSpace namespace
kubectl create namespace ${namespace} kubectl create namespace ${namespace}
# global variable # global variable
GetAccessTokenOf AccessToken GetAccessToken AccessToken
GetRegistryHost RegistryHost
GetK8sApiServer K8sApiServer
GetKongApiServer KongApiServer
GetKongRouteDomain KongRouteDomain
for servicePrefix in `ls ./src/Services|xargs -d '/'` for servicePrefix in `ls ./src/Services|xargs -d '/'`
do do
GetServiceName ${servicePrefix} serviceName GetServiceName ${servicePrefix} serviceName
......
...@@ -108,12 +108,41 @@ function GetReplicas() ...@@ -108,12 +108,41 @@ function GetReplicas()
eval $1=${count} eval $1=${count}
} }
function GetAccessTokenOf() function GetAccessToken()
{ {
declare token=($(grep -oP "(?<=${Environment}AccessToken>)[^<]+" "devops/deploy.props")) ToLower ${Environment} environment
declare token=($(grep -oP "(?<=AccessToken>)[^<]+" "devops/deploy.${environment}.props"))
eval $1="${token}" eval $1="${token}"
} }
function GetRegistryHost()
{
ToLower ${Environment} environment
declare host=($(grep -oP "(?<=RegistryHost>)[^<]+" "devops/deploy.${environment}.props"))
eval $1="${host}"
}
function GetK8sApiServer()
{
ToLower ${Environment} environment
declare host=($(grep -oP "(?<=K8sApiServer>)[^<]+" "devops/deploy.${environment}.props"))
eval $1="${host}"
}
function GetKongApiServer()
{
ToLower ${Environment} environment
declare host=($(grep -oP "(?<=KongApiServer>)[^<]+" "devops/deploy.${environment}.props"))
eval $1="${host}"
}
function GetKongRouteDomain()
{
ToLower ${Environment} environment
declare domain=($(grep -oP "(?<=KongRouteDomain>)[^<]+" "devops/deploy.${environment}.props"))
eval $1="${domain}"
}
function IsPublishableOf() function IsPublishableOf()
{ {
declare prefix=$0 declare prefix=$0
......
<Project>
<PropertyGroup>
<RegistryHost>dockerhub.geekbuying.com:8100</RegistryHost>
<K8sApiServer>https://10.76.134.3:6443</K8sApiServer>
<KongApiServer>http://10.76.134.4:81</KongApiServer>
<KongRouteDomain>s.geekbuying.com</KongRouteDomain>
<AccessToken>eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXhwamRyIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI4ZjYyNjk3NS05OWRlLTExZTgtOTU5YS0wNjc5ZjViMzhiN2IiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.NE5AHZWWdRb_ml2SfliIfcOcP4_9I-UcTVyEQnQ2F3vAsxYkhUzhBBbB6G3UmW5cD-i_aTraYy5t6joZSVsDATyZBlSWWq1vSzXO6rsEW6xoagTsehAPRfUO-FkmtbJuPPtZUkn7fkUGVfcM_IvIEg6z_F7qGaSyOYbe9lvqzs9pRvfGMo0Vxe1RpvyrB0aHPIx6XHJrGjWsfD8f4rKI0f5oH2N9VOEETlPaMmVCKcf-b55RRdblYVZMyH9plEbdDQj9EgjvGKwtpAoxbxGpoagKu_T88cfyAPoua-2bWSQaZ_Eq5W7gon_F6sCZ8ENQj37YOwo0fRRzaqs2lGVd3g</AccessToken>
</PropertyGroup>
</Project>
...@@ -2,7 +2,5 @@ ...@@ -2,7 +2,5 @@
<PropertyGroup> <PropertyGroup>
<Replicas>1</Replicas> <Replicas>1</Replicas>
<ImageUserName>devopspipelines</ImageUserName> <ImageUserName>devopspipelines</ImageUserName>
<StagingAccessToken>eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXh3MnpkIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI4Y2IyNTA1ZC1iNGFlLTExZTgtYWNkNS0wMDE2M2UwMDFhMzAiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.XFuVK10f_D3eJ04tDRibl8zZGYe6wrCiSw7NQjnApvyQS7dF1igItH2Fh5HaA12JcslrsBBWRUu0A9ZPVHfq-MW4CNgff8UKAE76Y7rYWfHHjTYumZJJJeUi1QHlNFvWJy3s8yjM5P1RomFCZYysUHv3Z5DVWD4uaX_C78tJxMFQYfFYD0DJah1WBpO0_ymixveffLsB_v5YN9jreW2b2uyIfJTqcCbYVo_vy4jB1HDvAQuvC6k4CKACk8AjT-o1R9QrsSEbggZ_Rss_j2iOeONlG_vDFbzkqFbxg3QKu5ULi4FdL3qOQBjx9Fgi-oXINX8ELlyZs3dNW62Bm6_P3g</StagingAccessToken>
<ProductionAccessToken></ProductionAccessToken>
</PropertyGroup> </PropertyGroup>
</Project> </Project>
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<Replicas>1</Replicas> <RegistryHost>registry.geekbuying.com:8100</RegistryHost>
<ImageUserName></ImageUserName> <K8sApiServer>https://172.24.83.222:6443</K8sApiServer>
<K8sApiServer></K8sApiServer> <KongApiServer>http://127.0.0.1:81</KongApiServer>
<KongRouteDomain>staging-api.geekbuy.cn</KongRouteDomain>
<AccessToken>eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXh3MnpkIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI4Y2IyNTA1ZC1iNGFlLTExZTgtYWNkNS0wMDE2M2UwMDFhMzAiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.XFuVK10f_D3eJ04tDRibl8zZGYe6wrCiSw7NQjnApvyQS7dF1igItH2Fh5HaA12JcslrsBBWRUu0A9ZPVHfq-MW4CNgff8UKAE76Y7rYWfHHjTYumZJJJeUi1QHlNFvWJy3s8yjM5P1RomFCZYysUHv3Z5DVWD4uaX_C78tJxMFQYfFYD0DJah1WBpO0_ymixveffLsB_v5YN9jreW2b2uyIfJTqcCbYVo_vy4jB1HDvAQuvC6k4CKACk8AjT-o1R9QrsSEbggZ_Rss_j2iOeONlG_vDFbzkqFbxg3QKu5ULi4FdL3qOQBjx9Fgi-oXINX8ELlyZs3dNW62Bm6_P3g</AccessToken>
</PropertyGroup> </PropertyGroup>
</Project> </Project>
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