From 48d96c623a688245bb300ce50f5ad7ed4594c272 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Fri, 23 Feb 2024 11:42:35 -0500 Subject: [PATCH 1/3] [ci] Retry installing gradle/wrapper up to 5 times --- .ci/scripts/packaging-test.sh | 2 ++ .ci/scripts/run-gradle.sh | 1 + 2 files changed, 3 insertions(+) diff --git a/.ci/scripts/packaging-test.sh b/.ci/scripts/packaging-test.sh index 1626255c30b4f..62f0fdf33e969 100755 --- a/.ci/scripts/packaging-test.sh +++ b/.ci/scripts/packaging-test.sh @@ -69,6 +69,8 @@ sudo mkdir -p /elasticsearch/qa/ && sudo chown jenkins /elasticsearch/qa/ && ln # See: https://git-scm.com/docs/git-config/2.35.2#Documentation/git-config.txt-safedirectory git config --global --add safe.directory $WORKSPACE +for attempt in 1 2 3 4 5; do ./gradlew --version && break; echo "Failed to download gradle wrapper - attempt $attempt/5" && sleep 5; done + # sudo sets it's own PATH thus we use env to override that and call sudo annother time so we keep the secure root PATH # run with --continue to run both bats and java tests even if one fails # be explicit about Gradle home dir so we use the same even with sudo diff --git a/.ci/scripts/run-gradle.sh b/.ci/scripts/run-gradle.sh index af5db8a6b4063..7c60a9de48712 100755 --- a/.ci/scripts/run-gradle.sh +++ b/.ci/scripts/run-gradle.sh @@ -37,4 +37,5 @@ if [[ "$MAX_WORKERS" == "0" ]]; then fi set -e +for attempt in 1 2 3 4 5; do ./gradlew --version && break; echo "Failed to download gradle wrapper - attempt $attempt/5" && sleep 5; done $GRADLEW -S --max-workers=$MAX_WORKERS $@ From 2c58ca6d6848d53dffa818bb2e439d18bfaf5ec7 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Fri, 23 Feb 2024 11:51:17 -0500 Subject: [PATCH 2/3] Move gradlew retry loop --- .ci/scripts/packaging-test.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.ci/scripts/packaging-test.sh b/.ci/scripts/packaging-test.sh index 62f0fdf33e969..56a56f102decb 100755 --- a/.ci/scripts/packaging-test.sh +++ b/.ci/scripts/packaging-test.sh @@ -69,8 +69,6 @@ sudo mkdir -p /elasticsearch/qa/ && sudo chown jenkins /elasticsearch/qa/ && ln # See: https://git-scm.com/docs/git-config/2.35.2#Documentation/git-config.txt-safedirectory git config --global --add safe.directory $WORKSPACE -for attempt in 1 2 3 4 5; do ./gradlew --version && break; echo "Failed to download gradle wrapper - attempt $attempt/5" && sleep 5; done - # sudo sets it's own PATH thus we use env to override that and call sudo annother time so we keep the secure root PATH # run with --continue to run both bats and java tests even if one fails # be explicit about Gradle home dir so we use the same even with sudo @@ -78,6 +76,7 @@ sudo -E env \ PATH=$BUILD_JAVA_HOME/bin:`sudo bash -c 'echo -n $PATH'` \ --unset=ES_JAVA_HOME \ --unset=JAVA_HOME \ - SYSTEM_JAVA_HOME=`readlink -f -n $BUILD_JAVA_HOME` \ - ./gradlew -g $HOME/.gradle --scan --parallel --build-cache -Dorg.elasticsearch.build.cache.url=https://gradle-enterprise.elastic.co/cache/ --continue $@ + SYSTEM_JAVA_HOME=`readlink -f -n $BUILD_JAVA_HOME`; \ + for attempt in 1 2 3 4 5; do ./gradlew -g "$HOME/.gradle" --version && break; echo "Failed to download gradle wrapper - attempt $attempt/5" && sleep 5; done; \ + ./gradlew -g "$HOME/.gradle" --scan --parallel --build-cache -Dorg.elasticsearch.build.cache.url=https://gradle-enterprise.elastic.co/cache/ --continue $@ From 1ce49ecad9e3dcd51096fa7fdafeb967127da59f Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Fri, 23 Feb 2024 12:08:32 -0500 Subject: [PATCH 3/3] Move retry command again --- .ci/scripts/packaging-test.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.ci/scripts/packaging-test.sh b/.ci/scripts/packaging-test.sh index 56a56f102decb..da5033433b1ee 100755 --- a/.ci/scripts/packaging-test.sh +++ b/.ci/scripts/packaging-test.sh @@ -28,6 +28,8 @@ BUILD_JAVA_HOME=$HOME/.java/$ES_BUILD_JAVA rm -Rfv $HOME/.gradle/init.d/ && mkdir -p $HOME/.gradle/init.d cp -v .ci/init.gradle $HOME/.gradle/init.d +for attempt in 1 2 3 4 5; do ./gradlew --version && break; echo "Failed to download gradle wrapper - attempt $attempt/5" && sleep 5; done + unset JAVA_HOME if [ -f "/etc/os-release" ] ; then @@ -76,7 +78,6 @@ sudo -E env \ PATH=$BUILD_JAVA_HOME/bin:`sudo bash -c 'echo -n $PATH'` \ --unset=ES_JAVA_HOME \ --unset=JAVA_HOME \ - SYSTEM_JAVA_HOME=`readlink -f -n $BUILD_JAVA_HOME`; \ - for attempt in 1 2 3 4 5; do ./gradlew -g "$HOME/.gradle" --version && break; echo "Failed to download gradle wrapper - attempt $attempt/5" && sleep 5; done; \ - ./gradlew -g "$HOME/.gradle" --scan --parallel --build-cache -Dorg.elasticsearch.build.cache.url=https://gradle-enterprise.elastic.co/cache/ --continue $@ + SYSTEM_JAVA_HOME=`readlink -f -n $BUILD_JAVA_HOME` \ + ./gradlew -g $HOME/.gradle --scan --parallel --build-cache -Dorg.elasticsearch.build.cache.url=https://gradle-enterprise.elastic.co/cache/ --continue $@