debian-mirror-gitlab/app/uploaders/artifact_uploader.rb

40 lines
754 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
class ArtifactUploader < GitlabUploader
2015-11-26 14:37:03 +05:30
storage :file
2017-09-10 17:25:29 +05:30
attr_reader :job, :field
2015-11-26 14:37:03 +05:30
2017-09-10 17:25:29 +05:30
def self.local_artifacts_store
2015-11-26 14:37:03 +05:30
Gitlab.config.artifacts.path
end
def self.artifacts_upload_path
2017-09-10 17:25:29 +05:30
File.join(self.local_artifacts_store, 'tmp/uploads/')
2015-11-26 14:37:03 +05:30
end
2017-09-10 17:25:29 +05:30
def initialize(job, field)
@job, @field = job, field
2015-11-26 14:37:03 +05:30
end
def store_dir
2017-09-10 17:25:29 +05:30
default_local_path
2015-11-26 14:37:03 +05:30
end
def cache_dir
2017-09-10 17:25:29 +05:30
File.join(self.class.local_artifacts_store, 'tmp/cache')
end
def work_dir
File.join(self.class.local_artifacts_store, 'tmp/work')
end
private
def default_local_path
File.join(self.class.local_artifacts_store, default_path)
2015-11-26 14:37:03 +05:30
end
2017-09-10 17:25:29 +05:30
def default_path
File.join(job.created_at.utc.strftime('%Y_%m'), job.project_id.to_s, job.id.to_s)
end
2015-11-26 14:37:03 +05:30
end