From ba5bd2d937e413a11ae64a1fc6a3d088d48c8c2d Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 1 Feb 2023 14:50:41 +0000 Subject: [PATCH] environment test --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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} """ } }