Improve docker-build-to-jfrog pipeline
Build image not for each tag, using one pre-builded image for tagging
Change-Id: Ic11cf2f35c03d41ab36c94d609a0fd569789946d
diff --git a/docker-build-to-jfrog.groovy b/docker-build-to-jfrog.groovy
index 2973621..83fe66b 100644
--- a/docker-build-to-jfrog.groovy
+++ b/docker-build-to-jfrog.groovy
@@ -36,9 +36,13 @@
])
}
stage("build image"){
+ containerId = sh(
+ script: "docker build -f ${DOCKERFILE_PATH}/Dockerfile -q --rm . | awk -F':' '{print \$2}'",
+ returnStdout: true
+ ).trim().take(12)
imageTagsList << "${GERRIT_CHANGE_NUMBER}_${GERRIT_PATCHSET_NUMBER}"
for (imageTag in imageTagsList) {
- sh "docker build -f ${DOCKERFILE_PATH}/Dockerfile -t ${dockerRepository}/${projectNamespace}/${projectModule}:${imageTag} --rm ."
+ sh "docker tag ${containerId} ${dockerRepository}/${projectNamespace}/${projectModule}:${imageTag}"
}
}
stage("publish image"){