build.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/bash
  2. # Copyright 2015 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. # kubernetes-build job: Triggered by github checkins on a 5 minute
  16. # poll. We abort this job if it takes longer than 10m. (Typically this
  17. # job takes about ~5m as of 0.8.0, but it's actually not completely
  18. # hermetic right now due to things like the golang image. It can take
  19. # ~8m if you force it to be totally hermetic.)
  20. set -o errexit
  21. set -o nounset
  22. set -o pipefail
  23. set -o xtrace
  24. # !!! ALERT !!! Jenkins default $HOME is /var/lib/jenkins, which is
  25. # global across jobs. We change $HOME instead to ${WORKSPACE}, which
  26. # is an incoming variable Jenkins provides us for this job's scratch
  27. # space.
  28. export HOME=${WORKSPACE} # Nothing should want Jenkins $HOME
  29. export PATH=$PATH:/usr/local/go/bin
  30. export KUBE_SKIP_CONFIRMATIONS=y
  31. # Skip gcloud update checking
  32. export CLOUDSDK_COMPONENT_MANAGER_DISABLE_UPDATE_CHECK=true
  33. # FEDERATION?
  34. : ${FEDERATION:="false"}
  35. : ${KUBE_RELEASE_RUN_TESTS:="n"}
  36. # New kubernetes/release/push-ci-build.sh values
  37. # RELEASE_INFRA_PUSH=true when we're using kubernetes/release/push-ci-build.sh
  38. : ${RELEASE_INFRA_PUSH:="false"}
  39. # SET_NOMOCK_FLAG=true means we're doing full pushes and we pass --nomock to
  40. # push-ci-build.sh. This is set to false in the
  41. # testing jobs and only used in the RELEASE_INFRA_PUSH=true scope below.
  42. : ${SET_NOMOCK_FLAG:="true"}
  43. export KUBE_RELEASE_RUN_TESTS RELEASE_INFRA_PUSH FEDERATION SET_NOMOCK_FLAG
  44. # Clean stuff out. Assume the last build left the tree in an odd
  45. # state.
  46. rm -rf ~/.kube*
  47. make clean
  48. git clean -fdx
  49. # Uncomment if you want to purge the Docker cache completely each
  50. # build. It costs about 150s each build to pull the golang image and
  51. # rebuild the kube-build:cross image, but these rarely change.
  52. # docker ps -aq | xargs -r docker rm
  53. # docker images -q | xargs -r docker rmi
  54. # Build
  55. # Jobs explicitly set KUBE_FASTBUILD to desired settings.
  56. make release
  57. # Push to GCS?
  58. if [[ ${KUBE_SKIP_PUSH_GCS:-} =~ ^[yY]$ ]]; then
  59. echo "Not pushed to GCS..."
  60. elif ${RELEASE_INFRA_PUSH-}; then
  61. readonly release_infra_clone="${WORKSPACE}/_tmp/release.git"
  62. mkdir -p ${WORKSPACE}/_tmp
  63. git clone https://github.com/kubernetes/release ${release_infra_clone}
  64. if [[ ! -x ${release_infra_clone}/push-ci-build.sh ]]; then
  65. echo "FATAL: Something went wrong." \
  66. "${release_infra_clone}/push-ci-build.sh isn't available." \
  67. "Exiting..." >&2
  68. exit 1
  69. fi
  70. [[ -n "${KUBE_GCS_RELEASE_BUCKET-}" ]] \
  71. && bucket_flag="--bucket=${KUBE_GCS_RELEASE_BUCKET-}"
  72. ${FEDERATION} && federation_flag="--federation"
  73. ${SET_NOMOCK_FLAG} && mock_flag="--nomock"
  74. ${release_infra_clone}/push-ci-build.sh ${bucket_flag-} ${federation_flag-} \
  75. ${mock_flag-}
  76. else
  77. ./build/push-ci-build.sh
  78. fi
  79. sha256sum _output/release-tars/kubernetes*.tar.gz