diff --git a/Jenkinsfile b/Jenkinsfile index 146b236..279c6ed 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,9 +1,10 @@ -// Jenkinsfile — Kaniko build + K8s deploy (latest only) -def L = 'kaniko-and-deploy' -def REG = 'harbor.sayinfo.co.kr' -def IMAGE = 'sayit-helpdesk/helpdesk-service' // Harbor 프로젝트/레포 이름에 맞게 유지 또는 수정 -def APP_NS = 'sayit-helpdesk' // 실제 K8s 네임스페이스와 일치해야 함 -def DEPLOY = 'sayit-helpdesk-service' // 실제 Deployment 이름과 일치해야 함 +// Jenkinsfile — Kaniko build + K8s deploy (빌드번호 태그 사용) +def L = 'kaniko-and-deploy' +def REG = 'harbor.sayinfo.co.kr' +def IMAGE = 'sayit-helpdesk/helpdesk-service' // Harbor 프로젝트/레포 이름 +def APP_NS = 'sayit-helpdesk' // 실제 K8s 네임스페이스 +def DEPLOY = 'sayit-helpdesk-service' // 실제 Deployment 이름 +def IMAGE_TAG = "${env.BUILD_NUMBER}" podTemplate( label: L, @@ -104,7 +105,7 @@ spec: /kaniko/executor \\ --context=. \\ --dockerfile=Dockerfile \\ - --destination=${REG}/${IMAGE}:latest \\ + --destination=${REG}/${IMAGE}:${IMAGE_TAG} \\ --snapshot-mode=redo \\ --skip-tls-verify \\ --cache=true \\ @@ -113,12 +114,11 @@ spec: } } - stage('Deploy to Kubernetes') { + stage('Deploy to Kubernetes') { container('kubectl') { sh """ set -eux - kubectl -n ${APP_NS} set image deploy/${DEPLOY} ${DEPLOY}=${REG}/${IMAGE}:latest - kubectl -n ${APP_NS} rollout restart deploy/${DEPLOY} + kubectl -n ${APP_NS} set image deploy/${DEPLOY} ${DEPLOY}=${REG}/${IMAGE}:${IMAGE_TAG} kubectl -n ${APP_NS} rollout status deploy/${DEPLOY} --timeout=300s kubectl -n ${APP_NS} get deploy ${DEPLOY} -o wide