Fix bad build result comparison.

Also apply https://google.github.io/styleguide/shell.xml and
https://sipb.mit.edu/doc/safe-shell/ while I'm in here.
pull/3266/head
Thomas Stromberg 2018-10-19 16:00:06 -07:00
parent ae9f4b20c7
commit 0f57ffa836
1 changed files with 21 additions and 18 deletions

View File

@ -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}/