2018-06-27 07:23:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 18:09:10 +00:00
|
|
|
class ExpireBuildInstanceArtifactsWorker # rubocop:disable Scalability/IdempotentWorker
|
2017-11-28 16:08:30 +00:00
|
|
|
include ApplicationWorker
|
2016-10-07 09:11:02 +00:00
|
|
|
|
2019-10-18 11:11:44 +00:00
|
|
|
feature_category :continuous_integration
|
|
|
|
|
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
|
|
|
|
2020-05-21 21:08:31 +00:00
|
|
|
Gitlab::AppLogger.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
|