Class: Ci::PipelineArtifact
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ApplicationRecord
- Ci::PipelineArtifact
- Includes:
- Artifactable, Lockable, FileStoreMounter, Presentable, UpdateProjectStatistics
- Defined in:
- app/models/ci/pipeline_artifact.rb
Constant Summary collapse
- FILE_SIZE_LIMIT =
10.megabytes.freeze
- EXPIRATION_DATE =
1.week.freeze
- DEFAULT_FILE_NAMES =
{ code_coverage: 'code_coverage.json', code_quality_mr_diff: 'code_quality_mr_diff.json' }.freeze
- REPORT_TYPES =
{ code_coverage: :raw, code_quality_mr_diff: :raw }.freeze
Constants included from FileStoreMounter
FileStoreMounter::ALLOWED_FILE_FIELDS
Constants included from Artifactable
Artifactable::FILE_FORMAT_ADAPTERS, Artifactable::NotSupportedAdapterError, Artifactable::STORE_COLUMN
Constants inherited from ApplicationRecord
Constants included from ResetOnUnionError
ResetOnUnionError::MAX_RESET_PERIOD
Class Method Summary collapse
- .create_or_replace_for_pipeline!(pipeline:, file_type:, file:, size:, locked: :unknown) ⇒ Object
- .find_by_file_type(file_type) ⇒ Object
- .report_exists?(file_type) ⇒ Boolean
Instance Method Summary collapse
Methods included from Artifactable
Methods included from Gitlab::Ci::Artifacts::Logger
#log_artifacts_context, #log_artifacts_filesize, #log_build_dependencies, log_created, log_deleted
Methods included from AfterCommitQueue
#run_after_commit, #run_after_commit_or_now
Methods inherited from ApplicationRecord
Methods inherited from ApplicationRecord
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
Methods included from SensitiveSerializableHash
Class Method Details
.create_or_replace_for_pipeline!(pipeline:, file_type:, file:, size:, locked: :unknown) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/ci/pipeline_artifact.rb', line 56 def create_or_replace_for_pipeline!(pipeline:, file_type:, file:, size:, locked: :unknown) transaction do pipeline.pipeline_artifacts.find_by_file_type(file_type)&.destroy! pipeline.pipeline_artifacts.create!( file_type: file_type, project_id: pipeline.project_id, size: size, file: file, file_format: REPORT_TYPES[file_type], expire_at: EXPIRATION_DATE.from_now, locked: locked ) end rescue ActiveRecord::ActiveRecordError => err Gitlab::ErrorTracking.track_and_raise_exception(err, { pipeline_id: pipeline.id, file_type: file_type }) end |
.find_by_file_type(file_type) ⇒ Object
52 53 54 |
# File 'app/models/ci/pipeline_artifact.rb', line 52 def find_by_file_type(file_type) find_by(file_type: file_type) end |
.report_exists?(file_type) ⇒ Boolean
46 47 48 49 50 |
# File 'app/models/ci/pipeline_artifact.rb', line 46 def report_exists?(file_type) return false unless REPORT_TYPES.key?(file_type) where(file_type: file_type).exists? end |
Instance Method Details
#present ⇒ Object
75 76 77 |
# File 'app/models/ci/pipeline_artifact.rb', line 75 def present super(presenter_class: "Ci::PipelineArtifacts::#{self.file_type.camelize}Presenter".constantize) end |