
Add retry delay to wheels and docker image build scripts. TESTS ================================= * Build docker base image, wheels and one docker image * Check Jenkins logs and make sure scripts are called with --attempts and --retry-delay Story: 2010055 Task: 48106 Depends-On: https://review.opendev.org/c/starlingx/root/+/877119 Signed-off-by: Davlet Panech <davlet.panech@windriver.com> Change-Id: I771e092ef340db8e639c121c0ebc990790eb0568
81 lines
2.3 KiB
Bash
Executable File
81 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#
|
|
# Copyright (c) 2022 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
set -e
|
|
source $(dirname "$0")/lib/job_utils.sh
|
|
source $(dirname "$0")/lib/retries.sh
|
|
|
|
require_job_env BUILD_HOME
|
|
require_job_env DRY_RUN
|
|
require_job_env USE_DOCKER_CACHE
|
|
require_job_env BUILD_STREAM stable
|
|
require_job_env PUSH_DOCKER_IMAGES
|
|
declare_job_env PUBLISH_ROOT_URL
|
|
declare_job_env DOCKER_IMAGE_BASE
|
|
|
|
load_build_env
|
|
|
|
if [[ -n "$DOCKER_IMAGE_BASE" ]] ; then
|
|
bail "DOCKER_IMAGE_BASE is set, bailing out"
|
|
fi
|
|
|
|
# Backward compatibility for folks with old configs.
|
|
# Remove, or convert to bail/die after sufficient time has passed.
|
|
if [[ -z "$BUILD_BRANCH_FOR_IMAGE_TAG" ]] ; then
|
|
BUILD_BRANCH_FOR_IMAGE_TAG="${BUILD_BRANCH/#r\//rc-}"
|
|
fi
|
|
|
|
base_image_tag="${BUILD_BRANCH_FOR_IMAGE_TAG=}-${BUILD_STREAM}-$TIMESTAMP"
|
|
base_image_latest_tag="${BUILD_BRANCH_FOR_IMAGE_TAG=}-${BUILD_STREAM}-latest"
|
|
|
|
declare -a cmd=(
|
|
"./build-stx-base.sh"
|
|
"--os=$DOCKER_BASE_OS"
|
|
"--version=$base_image_tag"
|
|
"--attempts=$DOCKER_BUILD_RETRY_COUNT"
|
|
"--retry-delay=$DOCKER_BUILD_RETRY_DELAY"
|
|
"--stream=$BUILD_STREAM"
|
|
"--user=$DOCKER_REGISTRY_ORG"
|
|
"--latest"
|
|
"--latest-tag=$base_image_latest_tag"
|
|
)
|
|
|
|
if [[ -n "$DOCKER_REGISTRY" ]] ; then
|
|
cmd+=("--registry=$DOCKER_REGISTRY")
|
|
fi
|
|
|
|
if [[ "$USE_DOCKER_CACHE" == true ]] ; then
|
|
cmd+=("--cache")
|
|
fi
|
|
|
|
if $USE_POD_URLS_IN_DOCKER_IMAGES ; then
|
|
cmd+=("--local")
|
|
else
|
|
require_job_env PUBLISH_ROOT_URL
|
|
cmd+=("--repo 'deb [trusted=yes check-valid-until=0] $PUBLISH_URL/inputs/packages ./'")
|
|
cmd+=("--repo 'deb [trusted=yes check-valid-until=0] $PUBLISH_URL/outputs/std/packages ./'")
|
|
fi
|
|
|
|
# build-stx-base.sh can only push to one repo. We will push to any
|
|
# additional repos manually.
|
|
if $PUSH_DOCKER_IMAGES ; then
|
|
cmd+=("--push")
|
|
fi
|
|
|
|
# build it
|
|
stx_docker_cmd $DRY_RUN_ARG "cd \$MY_REPO/build-tools/build-docker-images && ${cmd[*]}"
|
|
|
|
# retag and push it to extra registries
|
|
if $PUSH_DOCKER_IMAGES ; then
|
|
for reg in $EXTRA_REGISTRY_PREFIX_LIST ; do
|
|
stx_docker_cmd $DRY_RUN_ARG "docker tag $DOCKER_REGISTRY/$DOCKER_REGISTRY_ORG/stx-$DOCKER_BASE_OS:$base_image_tag $reg/stx-$DOCKER_BASE_OS:$base_image_tag"
|
|
with_retries -d "$DOCKER_BUILD_RETRY_DELAY" "$DOCKER_BUILD_RETRY_COUNT" stx_docker_cmd $DRY_RUN_ARG "docker push $reg/stx-$DOCKER_BASE_OS:$base_image_tag"
|
|
done
|
|
fi
|
|
|