From d757c6d0ece7823a28c8601a56f567580aa8cf16 Mon Sep 17 00:00:00 2001 From: Dimitrios Apostolou Date: Thu, 6 Feb 2020 17:19:55 +0100 Subject: Try to catch all errors when sdkmanager installs Task-number: QTQAINFRA-3531 Change-Id: I008c31a824287c60e67a665d0c2a3aebec863929 Reviewed-by: Heikki Halmet --- coin/provisioning/common/linux/android_linux.sh | 7 ++++++- coin/provisioning/common/windows/android.ps1 | 3 +++ coin/provisioning/qtci-macos-10.13-x86_64/30-android.sh | 7 +++++-- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'coin') diff --git a/coin/provisioning/common/linux/android_linux.sh b/coin/provisioning/common/linux/android_linux.sh index 44bd2281..ca9110b8 100755 --- a/coin/provisioning/common/linux/android_linux.sh +++ b/coin/provisioning/common/linux/android_linux.sh @@ -37,6 +37,8 @@ # It also runs update for SDK API, latest SDK tools, latest platform-tools and build-tools version +set -e + # shellcheck source=../unix/DownloadURL.sh source "${BASH_SOURCE%/*}/../unix/DownloadURL.sh" # shellcheck source=../unix/check_and_set_proxy.sh @@ -80,8 +82,11 @@ else sudo chown -R qt:users "$targetFolder" fi -# Run the following command under `eval` or `sh -c` so that the shell properly splits it +# Stop the sdkmanager from printing thousands of lines of #hashmarks. +# Run the following command under `eval` or `sh -c` so that the shell properly splits it. sdkmanager_no_progress_bar_cmd="tr '\r' '\n' | grep -v '^\[[ =]*\]'" +# But don't let the pipeline hide sdkmanager failures. +set -o pipefail echo "Running SDK manager for platforms;$sdkApiLevel, platform-tools and build-tools;$sdkBuildToolsVersion." # shellcheck disable=SC2031 diff --git a/coin/provisioning/common/windows/android.ps1 b/coin/provisioning/common/windows/android.ps1 index 0ac07f8a..2cf18cdc 100644 --- a/coin/provisioning/common/windows/android.ps1 +++ b/coin/provisioning/common/windows/android.ps1 @@ -95,6 +95,9 @@ Out-File -FilePath C:\Utils\Android\licenses\android-sdk-license -Encoding utf8 # Get a PATH where Java's path is defined from previous provisioning [Environment]::SetEnvironmentVariable("PATH", [Environment]::GetEnvironmentVariable("PATH", "Machine"), "Process") +# Attempt to catch all errors of sdkmanager.bat, even when hidden behind a pipeline. +$ErrorActionPreference = "Stop" + cd $toolsFolder\bin\ $sdkmanager_args += "platforms;$sdkApiLevel", "platform-tools", "build-tools;$sdkBuildToolsVersion" $command = 'for($i=0;$i -lt 6;$i++) { $response += "y`n"}; $response | .\sdkmanager.bat @sdkmanager_args | Out-Null' diff --git a/coin/provisioning/qtci-macos-10.13-x86_64/30-android.sh b/coin/provisioning/qtci-macos-10.13-x86_64/30-android.sh index aa0935f0..bc123111 100755 --- a/coin/provisioning/qtci-macos-10.13-x86_64/30-android.sh +++ b/coin/provisioning/qtci-macos-10.13-x86_64/30-android.sh @@ -37,7 +37,7 @@ # It also runs update for SDK API, latest SDK tools, latest platform-tools and build-tools version -set -ex +set -e # shellcheck source=../common/unix/SetEnvVar.sh source "${BASH_SOURCE%/*}/../common/unix/SetEnvVar.sh" @@ -68,8 +68,11 @@ sudo unzip -q "$toolsSourceFile" -d "$sdkTargetFolder" echo "Changing ownership of Android files." sudo chown -R qt:wheel "$targetFolder" -# Run the following command under `eval` or `sh -c` so that the shell properly splits it +# Stop the sdkmanager from printing thousands of lines of #hashmarks. +# Run the following command under `eval` or `sh -c` so that the shell properly splits it. sdkmanager_no_progress_bar_cmd="tr '\r' '\n' | grep -v '^\[[ =]*\]'" +# But don't let the pipeline hide sdkmanager failures. +set -o pipefail echo "Running SDK manager for platforms;$sdkApiLevel, platform-tools and build-tools;$sdkBuildToolsVersion." (echo "y"; echo "y") | "$sdkTargetFolder/tools/bin/sdkmanager" \ -- cgit v1.2.3