test images: Use PULL_BASE_SHA for non-git image building

In the test image build jobs, the image-util.sh script is not being run in a git
repository, which causes git log to fail.

In this case, we can use the PULL_BASE_SHA set in cloudbuild.yaml instead.
This commit is contained in:
Claudiu Belu 2021-08-16 05:10:19 -07:00
parent cbb5ea8210
commit 00dd02f89c
2 changed files with 6 additions and 2 deletions

View File

@ -14,8 +14,8 @@ steps:
dir: ./test/images/
env:
- DOCKER_CLI_EXPERIMENTAL=enabled
- TAG=$_GIT_TAG
- BASE_REF=$_PULL_BASE_REF
- GIT_COMMIT_ID=$_PULL_BASE_SHA
- WHAT=$_WHAT
- REGISTRY=$_REGISTRY
# The default cloudbuild has HOME=/builder/home and docker buildx is in /root/.docker/cli-plugins/docker-buildx
@ -40,6 +40,8 @@ substitutions:
# _PULL_BASE_REF will contain the ref that was pushed to to trigger this build -
# a branch like 'master' or 'release-0.2', or a tag like 'v0.2'.
_PULL_BASE_REF: 'master'
# _PULL_BASE_SHA will contain the git SHA from which the image will be built from.
_PULL_BASE_SHA: '12345'
# _REGISTRY will contain the staging registry.
_REGISTRY: 'gcr.io/k8s-staging-e2e-test-images'
# _WHAT will contain the image name to be built and published to the staging registry.

View File

@ -36,7 +36,9 @@ source "${KUBE_ROOT}/hack/lib/util.sh"
# Mapping of go ARCH to actual architectures shipped part of multiarch/qemu-user-static project
declare -A QEMUARCHS=( ["amd64"]="x86_64" ["arm"]="arm" ["arm64"]="aarch64" ["ppc64le"]="ppc64le" ["s390x"]="s390x" )
GIT_COMMIT_ID=$(git log -1 --format=%h)
# NOTE(claudiub): In the test image build jobs, this script is not being run in a git repository,
# which would cause git log to fail. Instead, we can use the GIT_COMMIT_ID set in cloudbuild.yaml.
GIT_COMMIT_ID=$(git log -1 --format=%h || echo "${GIT_COMMIT_ID}")
windows_os_versions=(1809 2004 20H2)
declare -A WINDOWS_OS_VERSIONS_MAP