From 4160d13d74aae1247129e7c68addb282946acbd1 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Thu, 13 Jun 2019 16:45:01 -0700 Subject: [PATCH] Update to use new "DockerFroms" function See https://github.com/docker-library/official-images/pull/5929 --- multiarch/target-pipeline.groovy | 6 +++--- multiarch/vars.groovy | 11 +++++++---- update.sh/target-pipeline.groovy | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/multiarch/target-pipeline.groovy b/multiarch/target-pipeline.groovy index ea24d6a6..91a88b14 100644 --- a/multiarch/target-pipeline.groovy +++ b/multiarch/target-pipeline.groovy @@ -54,7 +54,7 @@ node(vars.node(env.ACT_ON_ARCH, env.ACT_ON_IMAGE)) { 'BASHBREW_FROMS_TEMPLATE=' + ''' {{- range $.Entries -}} {{- if not ($.SkipConstraints .) -}} - {{- $.DockerFrom . -}} + {{- $.DockerFroms . | join "\\n" -}} {{- "\\n" -}} {{- end -}} {{- end -}} @@ -77,8 +77,8 @@ node(vars.node(env.ACT_ON_ARCH, env.ACT_ON_IMAGE)) { # filter the above list via build-info/image-ids/xxx from the build jobs to see if our image on-disk is already fresh (since even a no-op "docker pull" takes a long time to come back with a result) parentsToPull=() for parent in $parents; do - if [[ "$parent" == mcr.microsoft.com/windows/* ]] || [[ "$parent" == microsoft/* ]]; then - # Windows image? pull it + if [[ "$parent" == */* ]]; then + # non-official / non-"local" image (Windows)? pull it parentsToPull+=( "$parent" ) continue fi diff --git a/multiarch/vars.groovy b/multiarch/vars.groovy index 8eeab868..521f0c35 100644 --- a/multiarch/vars.groovy +++ b/multiarch/vars.groovy @@ -82,18 +82,21 @@ def bashbrewBuildAndPush(context) { def success = [] for (tag in tags) { context.stage(tag) { withEnv(['tag=' + tag]) { - def tagFrom = sh(returnStdout: true, script: ''' - bashbrew cat --format '{{- .DockerFrom .TagEntry -}}' "$tag" + def tagFroms = sh(returnStdout: true, script: ''' + bashbrew cat --format '{{- .DockerFroms .TagEntry | join "\\n" -}}' "$tag" \\ + | sort -u ''').trim() def tagFailed = false if (failed.flatten().contains(tagFrom)) { tagFailed = true } else { - withEnv(['tagFrom=' + tagFrom]) { + withEnv(['tagFroms=' + tagFroms]) { tagFailed = (0 != sh(returnStatus: true, script: ''' # pre-build sanity check - [ "$tagFrom" = 'scratch' ] || docker inspect --type image "$tagFrom" > /dev/null + for tagFrom in $tagFroms; do + [ "$tagFrom" = 'scratch' ] || docker inspect --type image "$tagFrom" > /dev/null + done # retry building each tag up to three times bashbrew build "$tag" || bashbrew build "$tag" || bashbrew build "$tag" diff --git a/update.sh/target-pipeline.groovy b/update.sh/target-pipeline.groovy index abeb7593..0999b72f 100644 --- a/update.sh/target-pipeline.groovy +++ b/update.sh/target-pipeline.groovy @@ -215,7 +215,7 @@ node { stage('Pull') { retry(3) { sh '#!/bin/bash -ex' + """ - bashbrew cat -f '{{ range .Entries }}{{ \$.DockerFrom . }}{{ "\\n" }}{{ end }}' '${repo}' \\ + bashbrew cat -f '{{ range .Entries }}{{ \$.DockerFroms . | join "\\n" }}{{ "\\n" }}{{ end }}' '${repo}' \\ | sort -u \\ | grep -vE '^(scratch|mcr.microsoft.com/windows/(nanoserver|servercore)|microsoft/(nanoserver|windowsservercore):.*|${repo}:.*)\$' \\ | xargs -rtn1 docker pull \\