2020-07-14 12:09:14 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Ci
|
|
|
|
class PipelineSuccessUnlockArtifactsWorker
|
|
|
|
include ApplicationWorker
|
2021-04-30 18:10:09 +00:00
|
|
|
|
2021-07-21 12:09:35 +00:00
|
|
|
data_consistency :always
|
|
|
|
|
2021-04-30 18:10:09 +00:00
|
|
|
sidekiq_options retry: 3
|
2020-07-14 12:09:14 +00:00
|
|
|
include PipelineBackgroundQueue
|
|
|
|
|
|
|
|
idempotent!
|
|
|
|
|
|
|
|
def perform(pipeline_id)
|
|
|
|
::Ci::Pipeline.find_by_id(pipeline_id).try do |pipeline|
|
2022-09-27 15:13:43 +00:00
|
|
|
# TODO: Move this check inside the Ci::UnlockArtifactsService
|
|
|
|
# once the feature flags in it have been removed.
|
|
|
|
break unless pipeline.has_erasable_artifacts?
|
2020-07-14 12:09:14 +00:00
|
|
|
|
2021-10-29 12:14:45 +00:00
|
|
|
results = ::Ci::UnlockArtifactsService
|
2020-07-14 12:09:14 +00:00
|
|
|
.new(pipeline.project, pipeline.user)
|
|
|
|
.execute(pipeline.ci_ref, pipeline)
|
2021-10-29 12:14:45 +00:00
|
|
|
|
|
|
|
log_extra_metadata_on_done(:unlocked_pipelines, results[:unlocked_pipelines])
|
|
|
|
log_extra_metadata_on_done(:unlocked_job_artifacts, results[:unlocked_job_artifacts])
|
2020-07-14 12:09:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|