2017-08-25 08:15:27 -04:00
|
|
|
require 'logger'
|
2017-09-04 05:52:26 -04:00
|
|
|
require 'resolv-replace'
|
2017-08-25 08:15:27 -04:00
|
|
|
|
2020-01-23 01:08:32 -05:00
|
|
|
desc 'GitLab | Artifacts | Migrate files for artifacts to comply with new storage format'
|
2017-06-08 01:29:35 -04:00
|
|
|
namespace :gitlab do
|
|
|
|
namespace :artifacts do
|
|
|
|
task migrate: :environment do
|
2017-09-07 17:27:04 -04:00
|
|
|
logger = Logger.new(STDOUT)
|
2019-09-20 08:05:52 -04:00
|
|
|
logger.info('Starting transfer of artifacts to remote storage')
|
2017-09-07 17:27:04 -04:00
|
|
|
|
2019-09-20 08:05:52 -04:00
|
|
|
helper = Gitlab::Artifacts::MigrationHelper.new
|
2017-08-25 08:15:27 -04:00
|
|
|
|
2019-09-20 08:05:52 -04:00
|
|
|
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-03-13 09:42:43 -04:00
|
|
|
|
2019-09-20 08:05:52 -04:00
|
|
|
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-03-13 09:42:43 -04:00
|
|
|
rescue => e
|
2019-09-20 08:05:52 -04:00
|
|
|
logger.error(e.message)
|
2017-06-08 01:29:35 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|