diff --git a/hack/util.sh b/hack/util.sh index d489ab2a805..6772ab0bce9 100755 --- a/hack/util.sh +++ b/hack/util.sh @@ -42,12 +42,18 @@ capz::util::should_build_kubernetes() { } capz::util::should_build_ccm() { + # TEST_CCM is an environment variable set by a prow job to indicate that the CCM should be built and tested. if [[ -n "${TEST_CCM:-}" ]]; then echo "true" && return fi + # If conformance is being tested with CI artifacts, CCM should be built. if [[ "${E2E_ARGS:-}" == "-kubetest.use-ci-artifacts" ]]; then echo "true" && return fi + # If the Kubernetes version contains "latest", CCM should be built. + if [[ "${KUBERNETES_VERSION:-}" =~ "latest" ]]; then + echo "true" && return + fi echo "false" } diff --git a/scripts/ci-entrypoint.sh b/scripts/ci-entrypoint.sh index 0d29d0b3553..061a8945e5d 100755 --- a/scripts/ci-entrypoint.sh +++ b/scripts/ci-entrypoint.sh @@ -50,7 +50,7 @@ setup() { # setup REGISTRY for custom images. : "${REGISTRY:?Environment variable empty or not defined.}" "${REPO_ROOT}/hack/ensure-acr-login.sh" - if [[ -n "${TEST_CCM:-}" ]]; then + if [[ "$(capz::util::should_build_ccm)" == "true" ]]; then # shellcheck source=scripts/ci-build-azure-ccm.sh source "${REPO_ROOT}/scripts/ci-build-azure-ccm.sh" echo "Will use the ${IMAGE_REGISTRY}/${CCM_IMAGE_NAME}:${IMAGE_TAG} cloud-controller-manager image for external cloud-provider-cluster"