Class: Ci::JobArtifact
Constant Summary
collapse
- TEST_REPORT_FILE_TYPES =
%w[junit].freeze
- COVERAGE_REPORT_FILE_TYPES =
%w[cobertura].freeze
- ACCESSIBILITY_REPORT_FILE_TYPES =
%w[accessibility].freeze
- NON_ERASABLE_FILE_TYPES =
%w[trace].freeze
- TERRAFORM_REPORT_FILE_TYPES =
%w[terraform].freeze
- UNSUPPORTED_FILE_TYPES =
%i[license_management].freeze
- DEFAULT_FILE_NAMES =
{
archive: nil,
metadata: nil,
trace: nil,
metrics_referee: nil,
network_referee: nil,
junit: 'junit.xml',
accessibility: 'gl-accessibility.json',
codequality: 'gl-code-quality-report.json',
sast: 'gl-sast-report.json',
secret_detection: 'gl-secret-detection-report.json',
dependency_scanning: 'gl-dependency-scanning-report.json',
container_scanning: 'gl-container-scanning-report.json',
dast: 'gl-dast-report.json',
license_management: 'gl-license-management-report.json',
license_scanning: 'gl-license-scanning-report.json',
performance: 'performance.json',
browser_performance: 'browser-performance.json',
load_performance: 'load-performance.json',
metrics: 'metrics.txt',
lsif: 'lsif.json',
dotenv: '.env',
cobertura: 'cobertura-coverage.xml',
terraform: 'tfplan.json',
cluster_applications: 'gl-cluster-applications.json',
requirements: 'requirements.json',
coverage_fuzzing: 'gl-coverage-fuzzing.json'
}.freeze
- INTERNAL_TYPES =
{
archive: :zip,
metadata: :gzip,
trace: :raw
}.freeze
- REPORT_TYPES =
{
junit: :gzip,
metrics: :gzip,
metrics_referee: :gzip,
network_referee: :gzip,
dotenv: :gzip,
cobertura: :gzip,
cluster_applications: :gzip,
lsif: :zip,
accessibility: :raw,
codequality: :raw,
sast: :raw,
secret_detection: :raw,
dependency_scanning: :raw,
container_scanning: :raw,
dast: :raw,
license_management: :raw,
license_scanning: :raw,
performance: :raw,
browser_performance: :raw,
load_performance: :raw,
terraform: :raw,
requirements: :raw,
coverage_fuzzing: :raw
}.freeze
- DOWNLOADABLE_TYPES =
%w[
accessibility
archive
cobertura
codequality
container_scanning
dast
dependency_scanning
dotenv
junit
license_management
license_scanning
lsif
metrics
performance
browser_performance
load_performance
sast
secret_detection
requirements
].freeze
- TYPE_AND_FORMAT_PAIRS =
INTERNAL_TYPES.merge(REPORT_TYPES).freeze
- PLAN_LIMIT_PREFIX =
'ci_max_artifact_size_'
Artifactable::FILE_FORMAT_ADAPTERS, Artifactable::NotSupportedAdapterError
Class Method Summary
collapse
Instance Method Summary
collapse
model_name, table_name_prefix
#each_blob
#run_after_commit, #run_after_commit_or_now
#background_upload, #changed_mounts
at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order
Class Method Details
.archived_trace_exists_for?(job_id) ⇒ Boolean
271
272
273
|
# File 'app/models/ci/job_artifact.rb', line 271
def self.archived_trace_exists_for?(job_id)
where(job_id: job_id).trace.take&.file&.file&.exists?
end
|
.artifacts_size_for(project) ⇒ Object
238
239
240
|
# File 'app/models/ci/job_artifact.rb', line 238
def self.artifacts_size_for(project)
self.where(project: project).sum(:size)
end
|
.associated_file_types_for(file_type) ⇒ Object
228
229
230
231
232
|
# File 'app/models/ci/job_artifact.rb', line 228
def self.associated_file_types_for(file_type)
return unless file_types.include?(file_type)
[file_type]
end
|
.max_artifact_size(type:, project:) ⇒ Object
275
276
277
278
279
280
281
282
283
284
|
# File 'app/models/ci/job_artifact.rb', line 275
def self.max_artifact_size(type:, project:)
limit_name = "#{PLAN_LIMIT_PREFIX}#{type}"
max_size = project.actual_limits.limit_for(
limit_name,
alternate_limit: -> { project.closest_setting(:max_artifacts_size) }
)
max_size&.megabytes.to_i
end
|
.total_size ⇒ Object
234
235
236
|
# File 'app/models/ci/job_artifact.rb', line 234
def self.total_size
self.sum(:size)
end
|
Instance Method Details
#expire_in ⇒ Object
260
261
262
|
# File 'app/models/ci/job_artifact.rb', line 260
def expire_in
expire_at - Time.current if expire_at
end
|
#expire_in=(value) ⇒ Object
#expired? ⇒ Boolean
252
253
254
|
# File 'app/models/ci/job_artifact.rb', line 252
def expired?
expire_at.present? && expire_at < Time.current
end
|
#expiring? ⇒ Boolean
256
257
258
|
# File 'app/models/ci/job_artifact.rb', line 256
def expiring?
expire_at.present? && expire_at > Time.current
end
|
#hashed_path? ⇒ Boolean
246
247
248
249
250
|
# File 'app/models/ci/job_artifact.rb', line 246
def hashed_path?
return true if trace?
super || self.file_location.nil?
end
|
#local_store? ⇒ Boolean
242
243
244
|
# File 'app/models/ci/job_artifact.rb', line 242
def local_store?
[nil, ::JobArtifactUploader::Store::LOCAL].include?(self.file_store)
end
|
222
223
224
225
226
|
# File 'app/models/ci/job_artifact.rb', line 222
def validate_file_format!
unless TYPE_AND_FORMAT_PAIRS[self.file_type&.to_sym] == self.file_format&.to_sym
errors.add(:base, _('Invalid file format with specified file type'))
end
end
|
214
215
216
217
218
219
220
|
# File 'app/models/ci/job_artifact.rb', line 214
def validate_supported_file_format!
return if Feature.disabled?(:drop_license_management_artifact, project, default_enabled: true)
if UNSUPPORTED_FILE_TYPES.include?(self.file_type&.to_sym)
errors.add(:base, _("File format is no longer supported"))
end
end
|