2021-03-11 19:13:27 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
require 'logger'
|
|
|
|
require 'resolv-replace'
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
desc 'GitLab | Artifacts | Migrate files for artifacts to comply with new storage format'
|
2018-05-09 12:01:36 +05:30
|
|
|
namespace :gitlab do
|
|
|
|
namespace :artifacts do
|
|
|
|
task migrate: :environment do
|
|
|
|
logger = Logger.new(STDOUT)
|
2019-12-21 20:55:43 +05:30
|
|
|
logger.info('Starting transfer of artifacts to remote storage')
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
helper = Gitlab::Artifacts::MigrationHelper.new
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
begin
|
|
|
|
helper.migrate_to_remote_storage do |artifact|
|
|
|
|
logger.info("Transferred artifact ID #{artifact.id} of type #{artifact.file_type} with size #{artifact.size} to object storage")
|
|
|
|
end
|
|
|
|
rescue => e
|
|
|
|
logger.error(e.message)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
task migrate_to_local: :environment do
|
|
|
|
logger = Logger.new(STDOUT)
|
|
|
|
logger.info('Starting transfer of artifacts to local storage')
|
|
|
|
|
|
|
|
helper = Gitlab::Artifacts::MigrationHelper.new
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
begin
|
|
|
|
helper.migrate_to_local_storage do |artifact|
|
|
|
|
logger.info("Transferred artifact ID #{artifact.id} of type #{artifact.file_type} with size #{artifact.size} to local storage")
|
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
rescue => e
|
2019-12-21 20:55:43 +05:30
|
|
|
logger.error(e.message)
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|