Skip to content

Commit a50a6b3

Browse files
committed
Updates getting version when downloading artifacts
1 parent f9086fe commit a50a6b3

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

rake_tasks/elasticsearch_tasks.rake

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ namespace :es do
7878
task :download_artifacts, :version do |_, args|
7979
json_filename = CURRENT_PATH.join('tmp/artifacts.json')
8080

81-
unless (version_number = args[:version] || ENV['STACK_VERSION'])
82-
# Get version number and build hash of running cluster:
83-
version_number = cluster_info['number']
84-
@build_hash = cluster_info['build_hash'] if cluster_info['build_hash']
85-
end
81+
version_number = args[:version] || ENV['STACK_VERSION'] || version_from_buildkite || version_from_running_cluster
8682

8783
# Create ./tmp if it doesn't exist
8884
Dir.mkdir(CURRENT_PATH.join('tmp'), 0700) unless File.directory?(CURRENT_PATH.join('tmp'))
@@ -123,6 +119,18 @@ namespace :es do
123119
File.write(CURRENT_PATH.join('tmp/rest-api-spec/build_hash'), @build_hash)
124120
end
125121

122+
def version_from_buildkite
123+
require 'yaml'
124+
yaml = YAML.load_file(File.expand_path('../.buildkite/pipeline.yml', __dir__))
125+
yaml['steps'].first['env']['STACK_VERSION']
126+
end
127+
128+
def version_from_running_cluster
129+
info = cluster_info
130+
@build_hash = info['build_hash'] if info['build_hash']
131+
info['number']
132+
end
133+
126134
desc 'Check Elasticsearch health'
127135
task :health do
128136
require 'elasticsearch'

0 commit comments

Comments
 (0)