From 88b47544483689748017628bfba46e058341f0ab Mon Sep 17 00:00:00 2001 From: Cizz22 Date: Mon, 13 Jan 2025 13:41:58 +0700 Subject: [PATCH] fix cicd --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2003806..2e38e6d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,9 +37,10 @@ pipeline { steps { script { // Build with commit hash tag + def commitHash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() sh ''' docker build -t ${DOCKER_HUB_USERNAME}/${IMAGE_NAME}:latest . - docker tag ${DOCKER_HUB_USERNAME}/${IMAGE_NAME}:latest ${DOCKER_HUB_USERNAME}/${IMAGE_NAME}:${GIT_COMMIT_HASH} + docker tag ${DOCKER_HUB_USERNAME}/${IMAGE_NAME}:latest ${DOCKER_HUB_USERNAME}/${IMAGE_NAME}:${commitHash} ''' } } @@ -47,9 +48,10 @@ pipeline { stage('Push to Docker Hub') { steps { + def commitHash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() sh ''' # Push both tags - docker push ${DOCKER_HUB_USERNAME}/${IMAGE_NAME}:${GIT_COMMIT_HASH} + docker push ${DOCKER_HUB_USERNAME}/${IMAGE_NAME}:${commitHash} docker push ${DOCKER_HUB_USERNAME}/${IMAGE_NAME}:latest ''' }