diff --git a/ci-automation/garbage_collect.sh b/ci-automation/garbage_collect.sh index 4bd2b691c4..cff5d441a5 100644 --- a/ci-automation/garbage_collect.sh +++ b/ci-automation/garbage_collect.sh @@ -24,9 +24,18 @@ # in the scripts repo. The newest 50 builds will be retained, # all older builds will be purged (50 is the default, see OPTIONAL INPUT above). -set -eu - function garbage_collect() { + # Run a subshell, so the traps, environment changes and global + # variables are not spilled into the caller. + ( + set -euo pipefail + + _garbage_collect_impl "${@}" + ) +} +# -- + +function _garbage_collect_impl() { local keep="${1:-50}" local dry_run="${DRY_RUN:-}" local purge_versions="${PURGE_VERSIONS:-}" @@ -144,3 +153,4 @@ function garbage_collect() { --env VMWARE_ESX_CREDS \ -w /work -v "$PWD":/work "${mantle_ref}" /work/ci-automation/garbage_collect_cloud.sh } +# -- diff --git a/ci-automation/image.sh b/ci-automation/image.sh index 87ac8ca65e..5c0234a9a6 100644 --- a/ci-automation/image.sh +++ b/ci-automation/image.sh @@ -32,9 +32,18 @@ # 2. "./ci-cleanup.sh" with commands to clean up temporary build resources, # to be run after this step finishes / when this step is aborted. -set -eu - function image_build() { + # Run a subshell, so the traps, environment changes and global + # variables are not spilled into the caller. + ( + set -euo pipefail + + _image_build_impl "${@}" + ) +} +# -- + +function _image_build_impl() { local arch="$1" source sdk_lib/sdk_container_common.sh diff --git a/ci-automation/packages.sh b/ci-automation/packages.sh index 40d1d9d19e..a3ae052d21 100644 --- a/ci-automation/packages.sh +++ b/ci-automation/packages.sh @@ -56,10 +56,18 @@ # 3. "./ci-cleanup.sh" with commands to clean up temporary build resources, # to be run after this step finishes / when this step is aborted. - -set -eu - function packages_build() { + # Run a subshell, so the traps, environment changes and global + # variables are not spilled into the caller. + ( + set -euo pipefail + + _packages_build_impl "${@}" + ) +} +# -- + +function _packages_build_impl() { local version="$1" local arch="$2" local coreos_git="${3:-}" diff --git a/ci-automation/push_pkgs.sh b/ci-automation/push_pkgs.sh index 2f65c886bd..78e25af599 100644 --- a/ci-automation/push_pkgs.sh +++ b/ci-automation/push_pkgs.sh @@ -31,8 +31,6 @@ # 2. "./ci-cleanup.sh" with commands to clean up temporary build resources, # to be run after this step finishes / when this step is aborted. -set -eu - # This function is run _inside_ the SDK container function image_build__copy_to_bincache() { local arch="$1" @@ -46,6 +44,17 @@ function image_build__copy_to_bincache() { # -- function push_packages() { + # Run a subshell, so the traps, environment changes and global + # variables are not spilled into the caller. + ( + set -euo pipefail + + _push_packages_impl "${@}" + ) +} +# -- + +function _push_packages_impl() { local arch="$1" source ci-automation/ci_automation_common.sh diff --git a/ci-automation/sdk_bootstrap.sh b/ci-automation/sdk_bootstrap.sh index 135f71cf6c..13b0c88020 100644 --- a/ci-automation/sdk_bootstrap.sh +++ b/ci-automation/sdk_bootstrap.sh @@ -48,9 +48,18 @@ # 3. "./ci-cleanup.sh" with commands to clean up temporary build resources, # to be run after this step finishes / when this step is aborted. -set -eu - function sdk_bootstrap() { + # Run a subshell, so the traps, environment changes and global + # variables are not spilled into the caller. + ( + set -euo pipefail + + _sdk_bootstrap_impl "${@}" + ) +} +# -- + +function _sdk_bootstrap_impl() { local seed_version="$1" local version="$2" local coreos_git="${3-}" diff --git a/ci-automation/sdk_container.sh b/ci-automation/sdk_container.sh index 01cffe632a..6234eb783c 100644 --- a/ci-automation/sdk_container.sh +++ b/ci-automation/sdk_container.sh @@ -29,9 +29,18 @@ # 2. "./ci-cleanup.sh" with commands to clean up temporary build resources, # to be run after this step finishes / when this step is aborted. -set -eu - function sdk_container_build() { + # Run a subshell, so the traps, environment changes and global + # variables are not spilled into the caller. + ( + set -euo pipefail + + _sdk_container_build_impl "${@}" + ) +} +# -- + +function _sdk_container_build_impl() { : ${ARCH:="amd64"} source ci-automation/ci_automation_common.sh diff --git a/ci-automation/test.sh b/ci-automation/test.sh index 8d7b48facd..18b2ffdacd 100644 --- a/ci-automation/test.sh +++ b/ci-automation/test.sh @@ -74,8 +74,6 @@ # script would need to make anyway. For more information, please refer # to the vendor_test.sh file. -set -euo pipefail - # Download torcx package and manifest, add build cache URL to manifest # so the docker.torcx-manifest-pkgs test can use it. function __prepare_torcx() { @@ -102,6 +100,17 @@ function __prepare_torcx() { # -- function test_run() { + # Run a subshell, so the traps, environment changes and global + # variables are not spilled into the caller. + ( + set -euo pipefail + + _test_run_impl "${@}" + ) +} +# -- + +function _test_run_impl() { local arch="$1" ; shift local image="$1"; shift diff --git a/ci-automation/vms.sh b/ci-automation/vms.sh index 7140fcf243..37da63af1a 100644 --- a/ci-automation/vms.sh +++ b/ci-automation/vms.sh @@ -31,9 +31,18 @@ # 2. "./ci-cleanup.sh" with commands to clean up temporary build resources, # to be run after this step finishes / when this step is aborted. -set -eu - function vm_build() { + # Run a subshell, so the traps, environment changes and global + # variables are not spilled into the caller. + ( + set -euo pipefail + + _vm_build_impl "${@}" + ) +} +# -- + +function _vm_build_impl() { local arch="$1" shift # $@ now contains image formats to build