Skip to content

Commit

Permalink
Update to use new "DockerFroms" function
Browse files Browse the repository at this point in the history
  • Loading branch information
tianon committed Jun 13, 2019
1 parent a34b8d3 commit 4160d13
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions multiarch/target-pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand All @@ -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
Expand Down
11 changes: 7 additions & 4 deletions multiarch/vars.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion update.sh/target-pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 \\
Expand Down

0 comments on commit 4160d13

Please sign in to comment.