From 1e3561e63eb01d14e968548dddb355348694cecb Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 9 Nov 2023 14:33:37 +0000 Subject: [PATCH] [CI] Updates artifact task for when there's no match in build hashes --- rake_tasks/elasticsearch_tasks.rake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rake_tasks/elasticsearch_tasks.rake b/rake_tasks/elasticsearch_tasks.rake index db48b543e2..c7129fa2e1 100644 --- a/rake_tasks/elasticsearch_tasks.rake +++ b/rake_tasks/elasticsearch_tasks.rake @@ -83,12 +83,12 @@ namespace :elasticsearch do exit 1 end - # Get the build hash if it hasn't been set from a running cluster - @build_hash ||= artifacts['version']['builds'].first.dig('projects', 'elasticsearch', 'commit_hash') - + # Either find the artifacts for the exact same build hash from the current running cluster or + # use the first one from the list of builds: build_hash_artifact = artifacts['version']['builds'].find do |build| build.dig('projects', 'elasticsearch', 'commit_hash') == @build_hash - end + end || artifacts['version']['builds'].first if build_hash_artifact.nil? + zip_url = build_hash_artifact.dig('projects', 'elasticsearch', 'packages').select { |k, _| k =~ /rest-resources-zip/ }.map { |_, v| v['url'] }.first # Dig into the elasticsearch packages, search for the rest-resources-zip package and return the URL: