build.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env 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. # Skip gcloud update checking
  31. export CLOUDSDK_COMPONENT_MANAGER_DISABLE_UPDATE_CHECK=true
  32. : "${KUBE_RELEASE_RUN_TESTS:="n"}"
  33. export KUBE_RELEASE_RUN_TESTS
  34. # Clean stuff out. Assume the last build left the tree in an odd
  35. # state.
  36. rm -rf ~/.kube*
  37. make clean
  38. # Uncomment if you want to purge the Docker cache completely each
  39. # build. It costs about 150s each build to pull the golang image and
  40. # rebuild the kube-build:cross image, but these rarely change.
  41. # docker ps -aq | xargs -r docker rm
  42. # docker images -q | xargs -r docker rmi
  43. # Build
  44. # Jobs explicitly set KUBE_FASTBUILD to desired settings.
  45. make release
  46. # Push to GCS?
  47. if [[ ${KUBE_SKIP_PUSH_GCS:-} =~ ^[yY]$ ]]; then
  48. echo "Not pushed to GCS..."
  49. else
  50. readonly release_infra_clone="${WORKSPACE}/_tmp/release.git"
  51. mkdir -p "${WORKSPACE}/_tmp"
  52. git clone https://github.com/kubernetes/release "${release_infra_clone}"
  53. push_build=${release_infra_clone}/push-build.sh
  54. [[ -n "${KUBE_GCS_RELEASE_BUCKET-}" ]] \
  55. && bucket_flag="--bucket=${KUBE_GCS_RELEASE_BUCKET-}"
  56. [[ -n "${KUBE_GCS_RELEASE_SUFFIX-}" ]] \
  57. && gcs_suffix_flag="--gcs-suffix=${KUBE_GCS_RELEASE_SUFFIX-}"
  58. "${push_build}" "${bucket_flag-}" "${gcs_suffix_flag-}" \
  59. --nomock --verbose --ci
  60. fi
  61. sha256sum _output/release-tars/kubernetes*.tar.gz