From d859d34739db7ffae04c3718a9984ab47817015c Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 29 Jun 2017 19:32:00 +0200 Subject: [PATCH] build: better error reporting of bash scripts (#5397) Currently whenever something fails in the deploy script it will likely not cause the CI to show the failure. This is because Bash by default doesn't exit the process with the proper error code. --- scripts/ci/build-and-test.sh | 1 + scripts/ci/publish-artifacts.sh | 3 +++ scripts/deploy/deploy-dashboard.sh | 3 +++ scripts/deploy/deploy-screenshot-functions.sh | 3 +++ scripts/deploy/publish-build-artifacts.sh | 3 ++- scripts/deploy/publish-docs-content.sh | 3 +++ 6 files changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/ci/build-and-test.sh b/scripts/ci/build-and-test.sh index 229a702f4a5..f9a9fd15e93 100755 --- a/scripts/ci/build-and-test.sh +++ b/scripts/ci/build-and-test.sh @@ -1,5 +1,6 @@ #!/bin/bash +# The script should immediately exit if any command in the script fails. set -e echo "" diff --git a/scripts/ci/publish-artifacts.sh b/scripts/ci/publish-artifacts.sh index b4be9e95bed..cc7d49fd0cd 100755 --- a/scripts/ci/publish-artifacts.sh +++ b/scripts/ci/publish-artifacts.sh @@ -3,6 +3,9 @@ # Script that runs after the testing stage of Travis passed. # Build artifacts and docs content will be published to different repositories. +# The script should immediately exit if any command in the script fails. +set -e + # Go to the project root directory cd $(dirname $0)/../.. diff --git a/scripts/deploy/deploy-dashboard.sh b/scripts/deploy/deploy-dashboard.sh index 46203a81c36..5e499e55a0f 100755 --- a/scripts/deploy/deploy-dashboard.sh +++ b/scripts/deploy/deploy-dashboard.sh @@ -1,5 +1,8 @@ #!/bin/bash +# The script should immediately exit if any command in the script fails. +set -e + # This script deploys the Dashboard App and their Cloud Functions to Firebase. # Before the script installs all dependencies and builds the dashboard app in production. diff --git a/scripts/deploy/deploy-screenshot-functions.sh b/scripts/deploy/deploy-screenshot-functions.sh index 1aad23bda36..8e2f490c8ed 100755 --- a/scripts/deploy/deploy-screenshot-functions.sh +++ b/scripts/deploy/deploy-screenshot-functions.sh @@ -1,5 +1,8 @@ #!/bin/bash +# The script should immediately exit if any command in the script fails. +set -e + # Go to the project root directory cd $(dirname ${0})/../.. diff --git a/scripts/deploy/publish-build-artifacts.sh b/scripts/deploy/publish-build-artifacts.sh index 8d3364c02eb..c060e394714 100755 --- a/scripts/deploy/publish-build-artifacts.sh +++ b/scripts/deploy/publish-build-artifacts.sh @@ -3,7 +3,8 @@ # Script to publish the build artifacts to a GitHub repository. # Builds will be automatically published once new changes are made to the repository. -set -e -o pipefail +# The script should immediately exit if any command in the script fails. +set -e # Go to the project root directory cd $(dirname ${0})/../.. diff --git a/scripts/deploy/publish-docs-content.sh b/scripts/deploy/publish-docs-content.sh index 3778cc6254d..b70e51ba975 100755 --- a/scripts/deploy/publish-docs-content.sh +++ b/scripts/deploy/publish-docs-content.sh @@ -3,6 +3,9 @@ # Publish material2 docs assets to the material2-docs-content repo # material.angular.io will pull from this assets repo to get the latest docs +# The script should immediately exit if any command in the script fails. +set -e + cd "$(dirname $0)/../../" docsPath="./dist/docs"