diff --git a/Jenkinsfile b/Jenkinsfile index d837cfa..c3526e5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -42,6 +42,8 @@ podTemplate( def shortGitCommit = "${gitCommit[0..10]}" def previousGitCommit = sh(script: "git rev-parse ${gitCommit}~", returnStdout: true) def docker_registry_url = "harbor.loafle.net" + def app_version_value = sh(returnStdout: true, script: "cat build.gradle | grep -o 'version = [^,]*'").trim() + def app_version = app_version_value.split(/=/)[1] stage('Test') { try { @@ -74,8 +76,8 @@ podTemplate( passwordVariable: 'HARBOR_PASSWORD']]) { sh """ docker login -u "${HARBOR_USER}" -p "${HARBOR_PASSWORD}" ${docker_registry_url} - docker build -t ${docker_registry_url}/prototype/cicd-java-spring-boot:${gitCommit} --build-arg JAR_NAME="cicd-${gitCommit}.jar" . - docker push ${docker_registry_url}/prototype/cicd-java-spring-boot:${gitCommit} + docker build -t ${docker_registry_url}/prototype/cicd-java-spring-boot:${app_version} --build-arg JAR_NAME="cicd-${app_version}.jar" . + docker push ${docker_registry_url}/prototype/cicd-java-spring-boot:${app_version} """ } }