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 16
16
17
17
set -xe
18
18
shopt -s globstar
19
+ # We spin up some subprocesses. Don't kill them on hangup
20
+ trap ' ' HUP
19
21
20
22
app_version=" "
21
23
22
24
# shellcheck disable=SC2120
23
25
delete_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} "
28
28
}
29
29
handle_error () {
30
30
errcode=$? # Remember the error code so we can exit with it after cleanup
31
31
32
32
# Clean up
33
- delete_app_version # shellcheck disable=SC2119
33
+ delete_app_version " $@ "
34
34
35
35
exit ${errcode}
36
36
}
37
- trap handle_error ERR
38
37
39
38
# First, style-check the shell scripts
40
39
shellcheck ./** /* .sh
@@ -45,16 +44,21 @@ find . -mindepth 2 -maxdepth 5 -name jenkins.sh -type f | while read -r path; do
45
44
# Use just the first letter of each subdir in version name
46
45
# shellcheck disable=SC2001
47
46
app_version=" jenkins-$( echo " ${dir# ./ } " | sed ' s#\([a-z]\)[^/]*/#\1-#g' ) "
47
+
48
+ trap ' handle_error $app_version' ERR
48
49
(
50
+ # If there's an error, clean up
51
+
49
52
pushd " ${dir} "
50
53
# Need different app versions because flex can't deploy over an existing
51
54
# version
52
55
GOOGLE_VERSION_ID=" ${app_version} " /bin/bash ./jenkins.sh
53
- echo " Return code: $? "
54
56
55
57
# Clean up the app version in the background
56
- nohup delete_app_version " ${app_version} " &
58
+ delete_app_version " ${app_version} " &
57
59
)
60
+ # Clear the trap
61
+ trap - ERR
58
62
done
59
63
60
64
wait
You can’t perform that action at this time.
0 commit comments