Merge "Fix properties setting in `docker-images-mirror`"
diff --git a/docker-mirror-images.groovy b/docker-mirror-images.groovy
index 522d044..c95c039 100644
--- a/docker-mirror-images.groovy
+++ b/docker-mirror-images.groovy
@@ -81,10 +81,16 @@
// Use sh-docker call for tag, due magic code in plugin:
// https://github.com/jenkinsci/docker-workflow-plugin/blob/docker-workflow-1.17/src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy#L168-L170
sh("docker tag ${srcImage.id} ${targetImageFull}")
+ String unique_image_id
common.infoMsg("Attempt to push docker image into remote registry: ${env.REGISTRY_URL}")
common.retry(3, 5) {
docker.withRegistry(env.REGISTRY_URL, env.TARGET_REGISTRY_CREDENTIALS_ID) {
- sh("docker push ${targetImageFull}")
+ unique_image_id = sh(
+ script: "docker push ${targetImageFull}",
+ returnStdout: true,
+ ).readLines().last().tokenize(' ')[2]
+ // This ^^^ will get digest from the last line of shell output
+ // <tag>: digest: <unique_image_id> size: <size>
}
}
def buildTime = new Date().format("yyyyMMdd-HH:mm:ss.SSS", TimeZone.getTimeZone('UTC'))
@@ -93,10 +99,6 @@
common.infoMsg("Processing artifactory props for : ${targetImageFull}")
LinkedHashMap artifactoryProperties = [:]
// Get digest of pushed image
- String unique_image_id = sh(
- script: "docker inspect --format='{{index .RepoDigests 0}}' '${targetImageFull}'",
- returnStdout: true,
- ).trim()
def image_sha256 = unique_image_id.tokenize(':')[1]
def ret = new URL("https://${targetRegistry}/artifactory/api/search/checksum?sha256=${image_sha256}").getText()
// Most probably, we would get many images, especially for external images. We need to guess