Skip to content

Commit

Permalink
checkout tag when deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Geapefurit committed Nov 22, 2023
1 parent 8e1298c commit e1715c0
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -337,26 +337,50 @@ pipeline {
}
}

stage('Deploy for test or prod') {
stage('Deploy for test') {
when {
expression { DEPLOY_TARGET == 'true' }
anyOf{
expression { TARGET_ENV ==~ /.*testing.*/ }
expression { TARGET_ENV ==~ /.*production.*/ }
}
}
steps {
sh(returnStdout: true, script: '''
tag=latest
set +e
result=$(echo $TARGET_ENV | grep "testing")
revlist=`git rev-list --tags --max-count=1`
rc=$?
set -e
if [[ "$result" != "" ]]
then
tag=$(git tag|grep '[13579]$'|sort -V|tail -n 1| tr -d '\n')
else
tag=$(git tag|grep '[02468]$'|sort -V|tail -n 1| tr -d '\n')
if [ ! 0 -eq $rc ]; then
exit 0
fi
tag=`git describe --tags $revlist`
git reset --hard
git checkout $tag
export CLOUD_PROXY_DOMAIN=cloud-proxy.$ROOT_DOMAIN # for gateway
export CLOUD_PROXY_GRPC_PORT=$DOMAIN_HTTP_PORT # for gateway
export CLOUD_CERT_NAME=$CERT_NAME # for webui and dashboard
export CLOUD_ROOT_DOMAIN=$ROOT_DOMAIN # for webui and dashboard
TAG=$tag make deploy-to-k8s-cluster
'''.stripIndent())
}
}

stage('Deploy for prod') {
when {
expression { DEPLOY_TARGET == 'true' }
anyOf{
expression { TARGET_ENV ==~ /.*testing.*/ }
expression { TARGET_ENV ==~ /.*production.*/ }
}
}
steps {
sh(returnStdout: true, script: '''
tag=$(git tag|grep '[02468]$'|sort -V|tail -n 1| tr -d '\n')
git reset --hard
git checkout $tag
export CLOUD_PROXY_DOMAIN=cloud-proxy.$ROOT_DOMAIN # for gateway
export CLOUD_PROXY_GRPC_PORT=$DOMAIN_HTTP_PORT # for gateway
Expand Down

0 comments on commit e1715c0

Please sign in to comment.