1#!/usr/bin/env bash 2# Copyright 2017 The Kubernetes Authors. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16# This script was used by bazel as the workspace_status_command to implement 17# build stamping with git information. 18# 19# It is still useful for obtaining kube::version::get_version_vars without 20# sourcing Kubernetes build internals. 21# 22# Usage: `hack/print-workspace-status.sh`. 23 24set -o errexit 25set -o nounset 26set -o pipefail 27 28KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. 29 30source "${KUBE_ROOT}/hack/lib/version.sh" 31kube::version::get_version_vars 32 33# Prefix with STABLE_ so that these values are saved to stable-status.txt 34# instead of volatile-status.txt. 35# Stamped rules will be retriggered by changes to stable-status.txt, but not by 36# changes to volatile-status.txt. 37# IMPORTANT: the camelCase vars should match the lists in hack/lib/version.sh 38# and staging/src/k8s.io/kubectl/pkg/version/def.bzl. 39cat <<EOF 40STABLE_BUILD_GIT_COMMIT ${KUBE_GIT_COMMIT-} 41STABLE_BUILD_SCM_STATUS ${KUBE_GIT_TREE_STATE-} 42STABLE_BUILD_SCM_REVISION ${KUBE_GIT_VERSION-} 43STABLE_BUILD_MAJOR_VERSION ${KUBE_GIT_MAJOR-} 44STABLE_BUILD_MINOR_VERSION ${KUBE_GIT_MINOR-} 45STABLE_DOCKER_TAG ${KUBE_GIT_VERSION/+/_} 46STABLE_DOCKER_REGISTRY ${KUBE_DOCKER_REGISTRY:-k8s.gcr.io} 47STABLE_DOCKER_PUSH_REGISTRY ${KUBE_DOCKER_PUSH_REGISTRY:-${KUBE_DOCKER_REGISTRY:-staging-k8s.gcr.io}} 48gitCommit ${KUBE_GIT_COMMIT-} 49gitTreeState ${KUBE_GIT_TREE_STATE-} 50gitVersion ${KUBE_GIT_VERSION-} 51gitMajor ${KUBE_GIT_MAJOR-} 52gitMinor ${KUBE_GIT_MINOR-} 53buildDate $(date \ 54 ${SOURCE_DATE_EPOCH:+"--date=@${SOURCE_DATE_EPOCH}"} \ 55 -u +'%Y-%m-%dT%H:%M:%SZ') 56EOF 57