Skip to content

Commit fe099b2

Browse files
authored
Merge pull request kubernetes#104393 from claudiubelu/test-images/git-tag
test images: Use PULL_BASE_SHA for non-git image building
2 parents 74a09fe + 00dd02f commit fe099b2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

test/images/cloudbuild.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ steps:
1414
dir: ./test/images/
1515
env:
1616
- DOCKER_CLI_EXPERIMENTAL=enabled
17-
- TAG=$_GIT_TAG
1817
- BASE_REF=$_PULL_BASE_REF
18+
- GIT_COMMIT_ID=$_PULL_BASE_SHA
1919
- WHAT=$_WHAT
2020
- REGISTRY=$_REGISTRY
2121
# The default cloudbuild has HOME=/builder/home and docker buildx is in /root/.docker/cli-plugins/docker-buildx
@@ -40,6 +40,8 @@ substitutions:
4040
# _PULL_BASE_REF will contain the ref that was pushed to to trigger this build -
4141
# a branch like 'master' or 'release-0.2', or a tag like 'v0.2'.
4242
_PULL_BASE_REF: 'master'
43+
# _PULL_BASE_SHA will contain the git SHA from which the image will be built from.
44+
_PULL_BASE_SHA: '12345'
4345
# _REGISTRY will contain the staging registry.
4446
_REGISTRY: 'gcr.io/k8s-staging-e2e-test-images'
4547
# _WHAT will contain the image name to be built and published to the staging registry.

test/images/image-util.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ source "${KUBE_ROOT}/hack/lib/util.sh"
3636
# Mapping of go ARCH to actual architectures shipped part of multiarch/qemu-user-static project
3737
declare -A QEMUARCHS=( ["amd64"]="x86_64" ["arm"]="arm" ["arm64"]="aarch64" ["ppc64le"]="ppc64le" ["s390x"]="s390x" )
3838

39-
GIT_COMMIT_ID=$(git log -1 --format=%h)
39+
# NOTE(claudiub): In the test image build jobs, this script is not being run in a git repository,
40+
# which would cause git log to fail. Instead, we can use the GIT_COMMIT_ID set in cloudbuild.yaml.
41+
GIT_COMMIT_ID=$(git log -1 --format=%h || echo "${GIT_COMMIT_ID}")
4042
windows_os_versions=(1809 2004 20H2)
4143
declare -A WINDOWS_OS_VERSIONS_MAP
4244

0 commit comments

Comments
 (0)