#!/bin/bash set -euo pipefail VALIDATION_SCRIPTS_VERSION=2.7.1 GRADLE_ENTERPRISE_ACCESS_KEY=$(vault kv get -field=value secret/ci/elastic-elasticsearch/gradle-enterprise-api-key) export GRADLE_ENTERPRISE_ACCESS_KEY curl -s -L -O https://github.com/gradle/gradle-enterprise-build-validation-scripts/releases/download/v$VALIDATION_SCRIPTS_VERSION/develocity-gradle-build-validation-$VALIDATION_SCRIPTS_VERSION.zip && unzip -q -o develocity-gradle-build-validation-$VALIDATION_SCRIPTS_VERSION.zip # Create a temporary file tmpOutputFile=$(mktemp) trap "rm $tmpOutputFile" EXIT set +e develocity-gradle-build-validation/03-validate-local-build-caching-different-locations.sh -r https://github.com/elastic/elasticsearch.git -b $BUILDKITE_BRANCH --develocity-server https://gradle-enterprise.elastic.co -t precommit --fail-if-not-fully-cacheable | tee $tmpOutputFile # Capture the return value retval=$? set -e # Now read the content from the temporary file into a variable perfOutput=$(cat $tmpOutputFile | sed -n '/Performance Characteristics/,/See https:\/\/gradle.com\/bvs\/main\/Gradle.md#performance-characteristics for details./p' | sed '$d' | sed 's/\x1b\[[0-9;]*m//g') investigationOutput=$(cat $tmpOutputFile | sed -n '/Investigation Quick Links/,$p' | sed 's/\x1b\[[0-9;]*m//g') # Initialize HTML output variable summaryHtml="

Build Cache Performance Characteristics

" summaryHtml+="" # generate html for links summaryHtml+="

Investigation Links

" summaryHtml+="" cat << EOF | buildkite-agent annotate --context "ctx-validation-summary" --style "info" $summaryHtml EOF # Check if the command was successful if [ $retval -eq 0 ]; then echo "Experiment completed successfully" elif [ $retval -eq 1 ]; then echo "An invalid input was provided while attempting to run the experiment" elif [ $retval -eq 2 ]; then echo "One of the builds that is part of the experiment failed" elif [ $retval -eq 3 ]; then echo "The build was not fully cacheable for the given task graph" elif [ $retval -eq 3 ]; then echo "An unclassified, fatal error happened while running the experiment" fi exit $retval