2016-08-18 10:31:44 -04:00
|
|
|
class ArtifactUploader < GitlabUploader
|
2015-10-12 17:47:32 -04:00
|
|
|
storage :file
|
|
|
|
|
2017-05-04 17:02:51 -04:00
|
|
|
attr_reader :job, :field
|
2015-10-12 17:47:32 -04:00
|
|
|
|
2017-05-04 17:02:51 -04:00
|
|
|
def self.local_artifacts_store
|
2015-11-22 08:27:30 -05:00
|
|
|
Gitlab.config.artifacts.path
|
2015-10-12 17:47:32 -04:00
|
|
|
end
|
|
|
|
|
2017-05-04 17:02:51 -04:00
|
|
|
def initialize(job, field)
|
|
|
|
@job, @field = job, field
|
2015-10-12 17:47:32 -04:00
|
|
|
end
|
|
|
|
|
2017-05-04 17:02:51 -04:00
|
|
|
def store_dir
|
|
|
|
default_local_path
|
2015-10-12 17:47:32 -04:00
|
|
|
end
|
|
|
|
|
2017-05-04 17:02:51 -04:00
|
|
|
def cache_dir
|
|
|
|
File.join(self.class.local_artifacts_store, 'tmp/cache')
|
2015-10-12 17:47:32 -04:00
|
|
|
end
|
|
|
|
|
2017-05-04 17:02:51 -04:00
|
|
|
private
|
2015-10-12 17:47:32 -04:00
|
|
|
|
2017-05-04 17:02:51 -04:00
|
|
|
def default_local_path
|
|
|
|
File.join(self.class.local_artifacts_store, default_path)
|
2015-10-12 17:47:32 -04:00
|
|
|
end
|
|
|
|
|
2017-05-04 17:02:51 -04:00
|
|
|
def default_path
|
|
|
|
File.join(job.created_at.utc.strftime('%Y_%m'), job.project_id.to_s, job.id.to_s)
|
2016-01-14 13:45:43 -05:00
|
|
|
end
|
2015-10-12 17:47:32 -04:00
|
|
|
end
|