File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 1616
1717set -xe
1818shopt -s globstar
19+ # We spin up some subprocesses. Don't kill them on hangup
20+ trap ' ' HUP
1921
2022app_version=" "
2123
2224# shellcheck disable=SC2120
2325delete_app_version () {
24- if [ -n " ${app_version} " ] || [ $# -gt 0 ]; then
25- yes | gcloud --project=" ${GOOGLE_PROJECT_ID} " \
26- app versions delete " ${1-${app_version} } "
27- fi
26+ yes | gcloud --project=" ${GOOGLE_PROJECT_ID} " \
27+ app versions delete " ${1} "
2828}
2929handle_error () {
3030 errcode=$? # Remember the error code so we can exit with it after cleanup
3131
3232 # Clean up
33- delete_app_version # shellcheck disable=SC2119
33+ delete_app_version " $@ "
3434
3535 exit ${errcode}
3636}
37- trap handle_error ERR
3837
3938# First, style-check the shell scripts
4039shellcheck ./** /* .sh
@@ -45,16 +44,21 @@ find . -mindepth 2 -maxdepth 5 -name jenkins.sh -type f | while read -r path; do
4544 # Use just the first letter of each subdir in version name
4645 # shellcheck disable=SC2001
4746 app_version=" jenkins-$( echo " ${dir# ./ } " | sed ' s#\([a-z]\)[^/]*/#\1-#g' ) "
47+
48+ trap ' handle_error $app_version' ERR
4849 (
50+ # If there's an error, clean up
51+
4952 pushd " ${dir} "
5053 # Need different app versions because flex can't deploy over an existing
5154 # version
5255 GOOGLE_VERSION_ID=" ${app_version} " /bin/bash ./jenkins.sh
53- echo " Return code: $? "
5456
5557 # Clean up the app version in the background
56- nohup delete_app_version " ${app_version} " &
58+ delete_app_version " ${app_version} " &
5759 )
60+ # Clear the trap
61+ trap - ERR
5862done
5963
6064wait
You can’t perform that action at this time.
0 commit comments