Class: Ci::JobArtifacts::CreateService
- Inherits:
-
BaseService
- Object
- BaseService
- Ci::JobArtifacts::CreateService
- Includes:
- Gitlab::Utils::UsageData
- Defined in:
- app/services/ci/job_artifacts/create_service.rb
Constant Summary collapse
- LSIF_ARTIFACT_TYPE =
'lsif'
- OBJECT_STORAGE_ERRORS =
[ Errno::EIO, Google::Apis::ServerError, Signet::RemoteServerError ].freeze
Constants included from Gitlab::Utils::UsageData
Gitlab::Utils::UsageData::DISTRIBUTED_HLL_FALLBACK, Gitlab::Utils::UsageData::FALLBACK, Gitlab::Utils::UsageData::HISTOGRAM_FALLBACK, Gitlab::Utils::UsageData::MAX_BUCKET_SIZE
Instance Attribute Summary
Attributes inherited from BaseService
Instance Method Summary collapse
- #authorize(artifact_type:, filesize: nil) ⇒ Object
- #execute(artifacts_file, params, metadata_file: nil) ⇒ Object
-
#initialize(job) ⇒ CreateService
constructor
A new instance of CreateService.
Methods included from Gitlab::Utils::UsageData
#add, #add_metric, #alt_usage_data, #average, #count, #distinct_count, #estimate_batch_distinct_count, #histogram, #maximum_id, #measure_duration, #minimum_id, #redis_usage_data, #sum, #track_usage_event, #with_finished_at, #with_metadata, #with_prometheus_client
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
#initialize(job) ⇒ CreateService
Returns a new instance of CreateService.
16 17 18 19 20 |
# File 'app/services/ci/job_artifacts/create_service.rb', line 16 def initialize(job) @job = job @project = job.project @pipeline = job.pipeline end |
Instance Method Details
#authorize(artifact_type:, filesize: nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/services/ci/job_artifacts/create_service.rb', line 22 def (artifact_type:, filesize: nil) result = validate_requirements(artifact_type: artifact_type, filesize: filesize) return result unless result[:status] == :success headers = JobArtifactUploader.( has_length: false, maximum_size: max_size(artifact_type), use_final_store_path: true, final_store_path_root_id: project.id ) if lsif?(artifact_type) headers[:ProcessLsif] = true track_usage_event('i_source_code_code_intelligence', project.id) end success(headers: headers) end |
#execute(artifacts_file, params, metadata_file: nil) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/services/ci/job_artifacts/create_service.rb', line 41 def execute(artifacts_file, params, metadata_file: nil) result = validate_requirements(artifact_type: params[:artifact_type], filesize: artifacts_file.size) return result unless result[:status] == :success return success if sha256_matches_existing_artifact?(params[:artifact_type], artifacts_file) build_result = build_artifact(artifacts_file, params, ) return build_result unless build_result[:status] == :success artifact = build_result[:artifact] = build_result[:artifact_metadata] track_artifact_uploader(artifact) parse_result = parse_artifact(artifact) return parse_result unless parse_result[:status] == :success persist_artifact(artifact, ) end |