Welcome to mirror list, hosted at ThFree Co, Russian Federation.

process.rb « config « chain « pipeline « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5548fca320f742b01deeb7e3864493e0d303bc56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# frozen_string_literal: true

module Gitlab
  module Ci
    module Pipeline
      module Chain
        module Config
          class Process < Chain::Base
            include Chain::Helpers

            def perform!
              raise ArgumentError, 'missing config content' unless @command.config_content

              result = logger.instrument(:pipeline_config_process) do
                processor = ::Gitlab::Ci::YamlProcessor.new(
                  @command.config_content, {
                    project: project,
                    pipeline: @pipeline,
                    sha: @pipeline.sha,
                    source: @pipeline.source,
                    user: current_user,
                    parent_pipeline: parent_pipeline,
                    logger: logger
                  }
                )

                processor.execute
              end

              add_warnings_to_pipeline(result.warnings)

              if result.valid?
                @command.yaml_processor_result = result
              else
                error(result.errors.first, config_error: true)
              end

              @pipeline.config_metadata = result.config_metadata

            rescue StandardError => ex
              Gitlab::ErrorTracking.track_exception(ex,
                project_id: project.id,
                sha: @pipeline.sha
              )

              error("Undefined error (#{Labkit::Correlation::CorrelationId.current_id})",
                config_error: true)
            end

            def break?
              @pipeline.errors.any? || @pipeline.persisted?
            end

            private

            def add_warnings_to_pipeline(warnings)
              return unless warnings.present?

              warnings.each { |message| warning(message) }
            end
          end
        end
      end
    end
  end
end