diff options
Diffstat (limited to 'app/services/ci/create_job_artifacts_service.rb')
-rw-r--r-- | app/services/ci/create_job_artifacts_service.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/services/ci/create_job_artifacts_service.rb b/app/services/ci/create_job_artifacts_service.rb index 5d7d552dc5a..f0ffe67510b 100644 --- a/app/services/ci/create_job_artifacts_service.rb +++ b/app/services/ci/create_job_artifacts_service.rb @@ -46,6 +46,11 @@ module Ci expire_in: expire_in) end + if Feature.enabled?(:keep_latest_artifact_for_ref, job.project) + artifact.locked = true + artifact_metadata&.locked = true + end + [artifact, artifact_metadata] end @@ -56,6 +61,7 @@ module Ci case artifact.file_type when 'dotenv' then parse_dotenv_artifact(job, artifact) + when 'cluster_applications' then parse_cluster_applications_artifact(job, artifact) else success end end @@ -64,6 +70,7 @@ module Ci Ci::JobArtifact.transaction do artifact.save! artifact_metadata&.save! + unlock_previous_artifacts!(artifact) # NOTE: The `artifacts_expire_at` column is already deprecated and to be removed in the near future. job.update_column(:artifacts_expire_at, artifact.expire_at) @@ -81,6 +88,12 @@ module Ci error(error.message, :bad_request) end + def unlock_previous_artifacts!(artifact) + return unless Feature.enabled?(:keep_latest_artifact_for_ref, artifact.job.project) + + Ci::JobArtifact.for_ref(artifact.job.ref, artifact.project_id).locked.update_all(locked: false) + end + def sha256_matches_existing_artifact?(job, artifact_type, artifacts_file) existing_artifact = job.job_artifacts.find_by_file_type(artifact_type) return false unless existing_artifact @@ -99,5 +112,9 @@ module Ci def parse_dotenv_artifact(job, artifact) Ci::ParseDotenvArtifactService.new(job.project, current_user).execute(artifact) end + + def parse_cluster_applications_artifact(job, artifact) + Clusters::ParseClusterApplicationsArtifactService.new(job, job.user).execute(artifact) + end end end |