print-workspace-status.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. # This command is used by bazel as the workspace_status_command
  16. # to implement build stamping with git information.
  17. set -o errexit
  18. set -o nounset
  19. set -o pipefail
  20. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
  21. source "${KUBE_ROOT}/hack/lib/version.sh"
  22. kube::version::get_version_vars
  23. # Prefix with STABLE_ so that these values are saved to stable-status.txt
  24. # instead of volatile-status.txt.
  25. # Stamped rules will be retriggered by changes to stable-status.txt, but not by
  26. # changes to volatile-status.txt.
  27. # IMPORTANT: the camelCase vars should match the lists in hack/lib/version.sh
  28. # and pkg/version/def.bzl.
  29. cat <<EOF
  30. STABLE_BUILD_GIT_COMMIT ${KUBE_GIT_COMMIT-}
  31. STABLE_BUILD_SCM_STATUS ${KUBE_GIT_TREE_STATE-}
  32. STABLE_BUILD_SCM_REVISION ${KUBE_GIT_VERSION-}
  33. STABLE_BUILD_MAJOR_VERSION ${KUBE_GIT_MAJOR-}
  34. STABLE_BUILD_MINOR_VERSION ${KUBE_GIT_MINOR-}
  35. STABLE_DOCKER_TAG ${KUBE_GIT_VERSION/+/_}
  36. STABLE_DOCKER_REGISTRY ${KUBE_DOCKER_REGISTRY:-k8s.gcr.io}
  37. STABLE_DOCKER_PUSH_REGISTRY ${KUBE_DOCKER_PUSH_REGISTRY:-${KUBE_DOCKER_REGISTRY:-staging-k8s.gcr.io}}
  38. gitCommit ${KUBE_GIT_COMMIT-}
  39. gitTreeState ${KUBE_GIT_TREE_STATE-}
  40. gitVersion ${KUBE_GIT_VERSION-}
  41. gitMajor ${KUBE_GIT_MAJOR-}
  42. gitMinor ${KUBE_GIT_MINOR-}
  43. buildDate $(date \
  44. ${SOURCE_DATE_EPOCH:+"--date=@${SOURCE_DATE_EPOCH}"} \
  45. -u +'%Y-%m-%dT%H:%M:%SZ')
  46. EOF