diff options
author | Robert Adam <krzmbrzl@gmail.com> | 2021-02-23 12:03:19 +0300 |
---|---|---|
committer | Robert Adam <krzmbrzl@gmail.com> | 2021-02-23 15:30:32 +0300 |
commit | 5b100c36789fe3baab5a25b89ba97008462401eb (patch) | |
tree | df9de18d8ddf060be73a3ab20307d87521bfd930 /.ci | |
parent | f19844769ed39409ce9fe7af1ac2851f1b4af2a2 (diff) |
CI(windows): Exit on error in build env install
The exit code of native commands (7zip in this case) was simply
ignored. Thus this commit makes sure these now cause the script to abort
and set the exit code accordingly.
Diffstat (limited to '.ci')
-rw-r--r-- | .ci/azure-pipelines/install-environment_windows.ps1 | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/.ci/azure-pipelines/install-environment_windows.ps1 b/.ci/azure-pipelines/install-environment_windows.ps1 index 885b484bf..11566da68 100644 --- a/.ci/azure-pipelines/install-environment_windows.ps1 +++ b/.ci/azure-pipelines/install-environment_windows.ps1 @@ -30,6 +30,22 @@ # Must match .7z and extracted folder name. # +# Always quit on encountered errors +$ErrorActionPreference = 'Stop' + +# We require a separate function that makes sure the run command's exit code +# is properly checked, so we can mimmick Bash's -e flag. +function Invoke-Command { + $command = $args[0] + $arguments = $args[1..($args.Length)] + & $command @arguments + + # Check for non-zero exit code + if ($LastExitCode -ne 0) { + Write-Error "Exit code $LastExitCode while running $command $arguments" + } +} + Set-Location -Path $env:AGENT_TEMPDIRECTORY $SOURCE_DIR = $env:BUILD_SOURCESDIRECTORY @@ -58,14 +74,14 @@ if (-Not (Test-Path (Join-Path $MUMBLE_ENVIRONMENT_STORE $MUMBLE_ENVIRONMENT_VER } Write-Host "Extracting build environment to $MUMBLE_ENVIRONMENT_STORE..." - 7z x $env_7z -o"$MUMBLE_ENVIRONMENT_STORE" + Invoke-Command 7z x $env_7z -o"$MUMBLE_ENVIRONMENT_STORE" } Write-Host "Downloading ASIO SDK..." try { Invoke-WebRequest -Uri "https://dl.mumble.info/build/extra/asio_sdk.zip" -OutFile "asio_sdk.zip" - 7z x "asio_sdk.zip" + Invoke-Command 7z x "asio_sdk.zip" Move-Item -Path "asiosdk_2.3.3_2019-06-14" -Destination "$SOURCE_DIR/3rdparty/asio" } catch { Write-Host "Failed to download ASIO SDK: $PSItem" @@ -76,7 +92,7 @@ Write-Host "Downloading G15 SDK..." try { Invoke-WebRequest -Uri "https://dl.mumble.info/build/extra/g15_sdk.zip" -OutFile "g15_sdk.zip" - 7z x "g15_sdk.zip" + Invoke-Command 7z x "g15_sdk.zip" Move-Item -Path "G15SDK/LCDSDK" -Destination "$SOURCE_DIR/3rdparty/g15" } catch { Write-Host "Failed to download G15 SDK: $PSItem" @@ -92,4 +108,4 @@ try { exit 1 } Write-Host "Exracting WixSharp to $env:AGENT_TOOLSDIRECTORY/WixSharp..." -7z x "WixSharp.1.15.0.0.7z" -o"$env:AGENT_TOOLSDIRECTORY/WixSharp" +Invoke-Command 7z x "WixSharp.1.15.0.0.7z" "-o$env:AGENT_TOOLSDIRECTORY/WixSharp" |