diff --git a/Jenkinsfile b/Jenkinsfile index bf0ac08..43cd3ec 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -81,7 +81,8 @@ spec: def OTEL_ENV = (TARGET_ENV == 'dev') ? 'dev' : (TARGET_ENV == 'stage') ? 'stage' : 'prod' def OTEL_SERVICE_NAME = (TARGET_ENV == 'dev') ? 'sayit-helpdesk-dev' : (TARGET_ENV == 'stage') ? 'sayit-helpdesk-stage' : 'sayit-helpdesk' - def IMAGE_TAG_PREFIX = (env.JOB_NAME?.contains('session')) ? "${TARGET_ENV}-session" : TARGET_ENV + def IS_SESSION_JOB = env.JOB_NAME?.contains('session') ? 'true' : 'false' + def IMAGE_TAG_PREFIX = (IS_SESSION_JOB == 'true') ? "${TARGET_ENV}-session" : TARGET_ENV def IMAGE_TAG = "${IMAGE_TAG_PREFIX}-${env.BUILD_NUMBER}" // dev-123 / dev-session-123 def LATEST_TAG = "latest-${IMAGE_TAG_PREFIX}" // latest-dev / latest-dev-session @@ -93,6 +94,7 @@ spec: echo "APP_NS = ${APP_NS}" echo "OTEL_ENV = ${OTEL_ENV}" echo "OTEL_SERVICE_NAME = ${OTEL_SERVICE_NAME}" + echo "IS_SESSION_JOB = ${IS_SESSION_JOB}" echo "IMAGE_TAG = ${IMAGE_TAG}" echo "LATEST_TAG = ${LATEST_TAG}" } @@ -147,12 +149,38 @@ spec: container('kubectl') { sh """ set -eux + if [ "${IS_SESSION_JOB}" = "true" ]; then + kubectl -n ${APP_NS} scale deploy/${DEPLOY} --replicas=0 + for i in \$(seq 1 150); do + POD_COUNT=\$(kubectl -n ${APP_NS} get pod -l app=${DEPLOY} --no-headers 2>/dev/null | wc -l | tr -d ' ') + [ "\${POD_COUNT}" = "0" ] && break + sleep 2 + if [ "\${i}" = "150" ]; then + kubectl -n ${APP_NS} get pod -l app=${DEPLOY} -o wide + exit 1 + fi + done + fi + kubectl -n ${APP_NS} set image deploy/${DEPLOY} ${DEPLOY}=${REG}/${IMAGE}:${IMAGE_TAG} + + if [ "${IS_SESSION_JOB}" = "true" ]; then + kubectl -n ${APP_NS} scale deploy/${DEPLOY} --replicas=1 + fi + kubectl -n ${APP_NS} rollout status deploy/${DEPLOY} --timeout=300s + DEPLOY_IMAGE=\$(kubectl -n ${APP_NS} get deploy ${DEPLOY} -o jsonpath='{.spec.template.spec.containers[0].image}') + test "\${DEPLOY_IMAGE}" = "${REG}/${IMAGE}:${IMAGE_TAG}" + kubectl -n ${APP_NS} get deploy ${DEPLOY} -o wide kubectl -n ${APP_NS} get pods -l app=${DEPLOY} -o wide kubectl -n ${APP_NS} get pod -l app=${DEPLOY} -o jsonpath='{.items[*].spec.containers[*].image}'; echo + + if [ "${IS_SESSION_JOB}" = "true" ]; then + POD_IMAGES=\$(kubectl -n ${APP_NS} get pod -l app=${DEPLOY} -o jsonpath='{.items[*].spec.containers[*].image}') + test "\${POD_IMAGES}" = "${REG}/${IMAGE}:${IMAGE_TAG}" + fi """ } } diff --git a/pom.xml b/pom.xml index b75aa68..96b6855 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ 2.1 1.9.13 4.5.2 - 1.3.5.RELEASE + 1.1.1.RELEASE diff --git a/src/main/resources/egovframework/spring/com/context-session.xml b/src/main/resources/egovframework/spring/com/context-session.xml index c0ad53d..bb11ebc 100644 --- a/src/main/resources/egovframework/spring/com/context-session.xml +++ b/src/main/resources/egovframework/spring/com/context-session.xml @@ -34,6 +34,5 @@ -