diff --git a/hack/jenkins/minikube_cross_build_and_upload.sh b/hack/jenkins/minikube_cross_build_and_upload.sh index 0aae48e1e2..4b54c1fe23 100755 --- a/hack/jenkins/minikube_cross_build_and_upload.sh +++ b/hack/jenkins/minikube_cross_build_and_upload.sh @@ -21,31 +21,35 @@ # ghprbPullId: The pull request ID, injected from the ghpbr plugin. # ghprbActualCommit: The commit hash, injected from the ghpbr plugin. -set -e +set -eux -o pipefail -export BUILD_IN_DOCKER=y -export TAG=$ghprbActualCommit -export GOPATH=/var/lib/jenkins/go +declare -rx BUILD_IN_DOCKER=y +declare -rx GOPATH=/var/lib/jenkins/go +declare -rx ISO_BUCKET="minikube-builds/${ghprbPullId}" +declare -rx ISO_VERSION="testing" +declare -rx TAG="${ghprbActualCommit}" + +readonly bucket="gs://minikube-builds" docker kill $(docker ps -q) || true docker rm $(docker ps -aq) || true -set +e -make -j 16 all -set -e +make -j 16 all && result=$? || result=$? -make_result="$?" -gsutil cp gs://minikube-builds/logs/index.html gs://minikube-builds/logs/${ghprbPullId}/index.html +gsutil cp gs://minikube-builds/logs/index.html \ + "gs://minikube-builds/logs/${ghprbPullId}/index.html" -# Exit if the cross build failed. -if [ "$make_result"-ne 0 ]; then echo "cross build failed"; exit 1; fi +if [[ "${result}" -ne 0 ]]; then + echo "build failed" + exit "${result}" +fi -# If there are ISO changes, build and upload the ISO -# then set the default to the newly built ISO for testing -if out="$(git diff ${ghprbActualCommit} --name-only $(git merge-base origin/master ${ghprbActualCommit}) | grep deploy/iso/minikube)" &> /dev/null; then + +git diff ${ghprbActualCommit} --name-only \ + $(git merge-base origin/master ${ghprbActualCommit}) \ + | grep -q deploy/iso/minikube && rebuild_iso=1 || rebuild_iso=0 + +if [[ "${rebuild_iso}" -eq 1 ]]; then echo "ISO changes detected ... rebuilding ISO" - export ISO_BUCKET="minikube-builds/${ghprbPullId}" - export ISO_VERSION="testing" - make release-iso fi @@ -54,5 +58,4 @@ cp -r test/integration/testdata out/ # Don't upload the buildroot artifacts if they exist rm -r out/buildroot || true -# Upload everything we built to Cloud Storage. gsutil -m cp -r out/* gs://minikube-builds/${ghprbPullId}/