2018-06-27 07:23:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-07 09:11:02 +00:00
|
|
|
class ExpireBuildInstanceArtifactsWorker
|
2017-11-28 16:08:30 +00:00
|
|
|
include ApplicationWorker
|
2016-10-07 09:11:02 +00:00
|
|
|
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-10-07 09:11:02 +00:00
|
|
|
def perform(build_id)
|
2016-10-14 09:30:06 +00:00
|
|
|
build = Ci::Build
|
|
|
|
.with_expired_artifacts
|
|
|
|
.reorder(nil)
|
|
|
|
.find_by(id: build_id)
|
2016-10-07 09:11:02 +00:00
|
|
|
|
2017-05-01 20:15:16 +00:00
|
|
|
return unless build&.project && !build.project.pending_delete
|
2016-10-14 09:30:06 +00:00
|
|
|
|
|
|
|
Rails.logger.info "Removing artifacts for build #{build.id}..."
|
2018-09-27 21:15:08 +00:00
|
|
|
build.erase_erasable_artifacts!
|
2016-10-07 09:11:02 +00:00
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-10-07 09:11:02 +00:00
|
|
|
end
|