Class: Ci::PipelineArtifacts::CreateCodeQualityMrDiffReportService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/ci/pipeline_artifacts/create_code_quality_mr_diff_report_service.rb

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(pipeline) ⇒ CreateCodeQualityMrDiffReportService

Returns a new instance of CreateCodeQualityMrDiffReportService.


7
8
9
# File 'app/services/ci/pipeline_artifacts/create_code_quality_mr_diff_report_service.rb', line 7

def initialize(pipeline)
  @pipeline = pipeline
end

Instance Method Details

#executeObject


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/ci/pipeline_artifacts/create_code_quality_mr_diff_report_service.rb', line 11

def execute
  return unless pipeline.can_generate_codequality_reports?
  return if pipeline.has_codequality_mr_diff_report?
  return unless new_errors_introduced?

  file = build_carrierwave_file!

  pipeline.pipeline_artifacts.create!(
    project_id: pipeline.project_id,
    file_type: :code_quality_mr_diff,
    file_format: Ci::PipelineArtifact::REPORT_TYPES.fetch(:code_quality_mr_diff),
    size: file["tempfile"].size,
    file: file,
    expire_at: Ci::PipelineArtifact::EXPIRATION_DATE.from_now
  )
end