Commit 4c145dbf authored by Tiffany Rea's avatar Tiffany Rea

Fix download job when dir not exist

parent c77a6f41
...@@ -75,13 +75,16 @@ module QA ...@@ -75,13 +75,16 @@ module QA
# Download files from GCS bucket by environment name # Download files from GCS bucket by environment name
# Delete the files afterward # Delete the files afterward
def download(ci_project_name) def download(ci_project_name)
files_list = gcs_storage.list_objects(BUCKET, prefix: ci_project_name).items.each_with_object([]) do |obj, arr| bucket_items = gcs_storage.list_objects(BUCKET, prefix: ci_project_name).items
files_list = bucket_items&.each_with_object([]) do |obj, arr|
arr << obj.name arr << obj.name
end end
return puts "\nNothing to download!" if files_list.empty? return puts "\nNothing to download!" if files_list.blank?
FileUtils.mkdir_p('tmp/') FileUtils.mkdir_p('tmp/')
files_list.each do |file_name| files_list.each do |file_name|
local_path = "tmp/#{file_name.split('/').last}" local_path = "tmp/#{file_name.split('/').last}"
Runtime::Logger.info("Downloading #{file_name} to #{local_path}") Runtime::Logger.info("Downloading #{file_name} to #{local_path}")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment